diff --git a/src/bin/main.rs b/src/bin/main.rs index 6db053a..d719aa5 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -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(); diff --git a/src/entity/account.rs b/src/entity/account.rs index 4699c09..60a23ac 100644 --- a/src/entity/account.rs +++ b/src/entity/account.rs @@ -21,9 +21,9 @@ pub struct NewUserAccountEntity { pub password: String, pub guildcard: u32, pub team_id: Option, - pub banned: bool, - pub muted_until: SystemTime, - pub created_at: SystemTime, + pub banned_until: Option>, + pub muted_until: Option>, + pub created_at: chrono::DateTime, pub flags: u32, } @@ -34,9 +34,9 @@ pub struct UserAccountEntity { pub password: String, pub guildcard: u32, pub team_id: Option, - pub banned: bool, - pub muted_until: SystemTime, - pub created_at: SystemTime, + pub banned_until: Option>, + pub muted_until: Option>, + pub created_at: chrono::DateTime, pub flags: u32, // TODO: is this used for anything other than character creation? } diff --git a/src/entity/gateway/inmemory.rs b/src/entity/gateway/inmemory.rs index 56da621..2801eb1 100644 --- a/src/entity/gateway/inmemory.rs +++ b/src/entity/gateway/inmemory.rs @@ -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, diff --git a/src/login/login.rs b/src/login/login.rs index bf19f22..22de67a 100644 --- a/src/login/login.rs +++ b/src/login/login.rs @@ -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 {