Disabled accounts can not login
This commit is contained in:
parent
9a4c725b4e
commit
123dc519af
@ -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))
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user