change banned from bool to timestamp
This commit is contained in:
parent
aa08e67f6b
commit
17a8b288c1
@ -56,9 +56,9 @@ fn main() {
|
||||
password: bcrypt::hash("qwer", 5).unwrap(),
|
||||
guildcard: i + 1,
|
||||
team_id: None,
|
||||
banned: false,
|
||||
muted_until: SystemTime::now(),
|
||||
created_at: SystemTime::now(),
|
||||
banned_until: None,
|
||||
muted_until: None,
|
||||
created_at: chrono::Utc::now(),
|
||||
flags: 0,
|
||||
};
|
||||
let fake_user = entity_gateway.create_user(fake_user).await.unwrap();
|
||||
|
@ -21,9 +21,9 @@ pub struct NewUserAccountEntity {
|
||||
pub password: String,
|
||||
pub guildcard: u32,
|
||||
pub team_id: Option<u32>,
|
||||
pub banned: bool,
|
||||
pub muted_until: SystemTime,
|
||||
pub created_at: SystemTime,
|
||||
pub banned_until: Option<chrono::DateTime<chrono::Utc>>,
|
||||
pub muted_until: Option<chrono::DateTime<chrono::Utc>>,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
pub flags: u32,
|
||||
}
|
||||
|
||||
@ -34,9 +34,9 @@ pub struct UserAccountEntity {
|
||||
pub password: String,
|
||||
pub guildcard: u32,
|
||||
pub team_id: Option<u32>,
|
||||
pub banned: bool,
|
||||
pub muted_until: SystemTime,
|
||||
pub created_at: SystemTime,
|
||||
pub banned_until: Option<chrono::DateTime<chrono::Utc>>,
|
||||
pub muted_until: Option<chrono::DateTime<chrono::Utc>>,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
pub flags: u32, // TODO: is this used for anything other than character creation?
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ impl EntityGateway for InMemoryGateway {
|
||||
password: user.password,
|
||||
guildcard: user.guildcard,
|
||||
team_id: user.team_id,
|
||||
banned: user.banned,
|
||||
banned_until: user.banned_until,
|
||||
muted_until: user.muted_until,
|
||||
created_at: user.created_at,
|
||||
flags: user.flags,
|
||||
|
@ -63,7 +63,7 @@ pub async fn get_login_status(entity_gateway: &impl EntityGateway, pkt: &Login)
|
||||
let user = entity_gateway.get_user_by_name(username).await.ok_or(AccountStatus::InvalidUser)?;
|
||||
let verified = bcrypt::verify(password, user.password.as_str()).map_err(|_err| AccountStatus::Error)?;
|
||||
match verified {
|
||||
true => if user.banned {
|
||||
true => if user.banned_until.map(|banned| banned > chrono::Utc::now()).unwrap_or(false) {
|
||||
Err(AccountStatus::Banned)
|
||||
}
|
||||
else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user