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 {
|
pub enum LoginResult {
|
||||||
AccountNotFound,
|
AccountNotFound,
|
||||||
InvalidPassword,
|
InvalidPassword,
|
||||||
|
AccountDisabled,
|
||||||
Success(User),
|
Success(User),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +55,10 @@ impl Handler<LoginRequest> for UsersActor {
|
|||||||
return MessageResult(LoginResult::InvalidPassword);
|
return MessageResult(LoginResult::InvalidPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !user.enabled {
|
||||||
|
return MessageResult(LoginResult::AccountDisabled);
|
||||||
|
}
|
||||||
|
|
||||||
MessageResult(LoginResult::Success(user))
|
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 => {
|
c => {
|
||||||
// TODO : add bruteforce detection
|
// TODO : add bruteforce detection
|
||||||
log::warn!("Failed login for username {} : {:?}", login, c);
|
log::warn!("Failed login for username {} : {:?}", login, c);
|
||||||
|
Loading…
Reference in New Issue
Block a user