Disabled accounts can not login

This commit is contained in:
Pierre HUBERT 2022-04-03 14:42:16 +02:00
parent 9a4c725b4e
commit 123dc519af
2 changed files with 10 additions and 0 deletions

View File

@ -7,6 +7,7 @@ use crate::data::user::{User, UserID, verify_password};
pub enum LoginResult {
AccountNotFound,
InvalidPassword,
AccountDisabled,
Success(User),
}
@ -54,6 +55,10 @@ impl Handler<LoginRequest> for UsersActor {
return MessageResult(LoginResult::InvalidPassword);
}
if !user.enabled {
return MessageResult(LoginResult::AccountDisabled);
}
MessageResult(LoginResult::Success(user))
}
}

View File

@ -114,6 +114,11 @@ pub async fn login_route(users: web::Data<Addr<UsersActor>>,
}
}
LoginResult::AccountDisabled => {
log::warn!("Failed login for username {} : account is disabled", login);
danger = "Your account is disabled!".to_string();
}
c => {
// TODO : add bruteforce detection
log::warn!("Failed login for username {} : {:?}", login, c);