Start to create 2FA exemption after successful 2FA login
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@ -139,7 +139,8 @@ pub async fn login_route(
|
||||
LoginResult::Success(user) => {
|
||||
let status = if user.need_reset_password {
|
||||
SessionStatus::NeedNewPassword
|
||||
} else if user.has_two_factor() {
|
||||
} else if user.has_two_factor() && !user.can_bypass_two_factors_for_ip(remote_ip.0)
|
||||
{
|
||||
SessionStatus::Need2FA
|
||||
} else {
|
||||
SessionStatus::SignedIn
|
||||
@ -326,6 +327,7 @@ pub async fn login_with_otp(
|
||||
form: Option<web::Form<LoginWithOTPForm>>,
|
||||
users: web::Data<Addr<UsersActor>>,
|
||||
http_req: HttpRequest,
|
||||
remote_ip: RemoteIP,
|
||||
) -> impl Responder {
|
||||
let mut danger = None;
|
||||
|
||||
@ -354,6 +356,11 @@ pub async fn login_with_otp(
|
||||
{
|
||||
danger = Some("Specified code is invalid!".to_string());
|
||||
} else {
|
||||
users
|
||||
.send(users_actor::AddSuccessful2FALogin(user.uid, remote_ip.0))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
SessionIdentity(id.as_ref()).set_status(&http_req, SessionStatus::SignedIn);
|
||||
return redirect_user(query.redirect.get());
|
||||
}
|
||||
|
Reference in New Issue
Block a user