|
@ -0,0 +1,44 @@ |
|
|
|
|
|
use std::time::SystemTime;
|
|
|
|
|
|
//use diesel::sql_types::Timestamp;
|
|
|
|
|
|
use diesel::{Insertable, Queryable, Identifiable, Associations};
|
|
|
|
|
|
//use bcrypt::{DEFAULT_COST, hash};
|
|
|
|
|
|
//use diesel::serialize::ToSql;
|
|
|
|
|
|
use libpso:: |
|
|
|
|
|
|
|
|
|
|
|
use elseware::schema::*;
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Identifiable, Debug)]
|
|
|
|
|
|
pub struct UserAccount {
|
|
|
|
|
|
pub id: i32,
|
|
|
|
|
|
pub username: String,
|
|
|
|
|
|
pub password: String,
|
|
|
|
|
|
pub guildcard: Option<i32>,
|
|
|
|
|
|
pub team_id: Option<i32>,
|
|
|
|
|
|
pub banned: bool,
|
|
|
|
|
|
pub muted_until: SystemTime,
|
|
|
|
|
|
pub created_at: SystemTime,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Insertable)]
|
|
|
|
|
|
#[table_name="user_accounts"]
|
|
|
|
|
|
pub struct NewUser {
|
|
|
|
|
|
username: String,
|
|
|
|
|
|
password: String,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl NewUser {
|
|
|
|
|
|
pub fn new(username: String, password: String) -> NewUser {
|
|
|
|
|
|
let crypt_password = bcrypt::hash(password, bcrypt::DEFAULT_COST).expect("could not hash password?");
|
|
|
|
|
|
NewUser {
|
|
|
|
|
|
username: username,
|
|
|
|
|
|
password: crypt_password,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Identifiable, Associations, Debug)]
|
|
|
|
|
|
pub struct UserSettings {
|
|
|
|
|
|
id: i32,
|
|
|
|
|
|
user_id: i32,
|
|
|
|
|
|
settings_blob: [u32; 0x1160],
|
|
|
|
|
|
}
|