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:
@ -1,3 +1,7 @@
|
||||
use crate::actors::users_actor;
|
||||
use crate::actors::users_actor::UsersActor;
|
||||
use crate::data::remote_ip::RemoteIP;
|
||||
use actix::Addr;
|
||||
use actix_identity::Identity;
|
||||
use actix_web::{web, HttpRequest, HttpResponse, Responder};
|
||||
use webauthn_rs::prelude::PublicKeyCredential;
|
||||
@ -16,6 +20,8 @@ pub async fn auth_webauthn(
|
||||
req: web::Json<AuthWebauthnRequest>,
|
||||
manager: WebAuthManagerReq,
|
||||
http_req: HttpRequest,
|
||||
remote_ip: RemoteIP,
|
||||
users: web::Data<Addr<UsersActor>>,
|
||||
) -> impl Responder {
|
||||
if !SessionIdentity(Some(&id)).need_2fa_auth() {
|
||||
return HttpResponse::Unauthorized().json("No 2FA required!");
|
||||
@ -25,6 +31,11 @@ pub async fn auth_webauthn(
|
||||
|
||||
match manager.finish_authentication(&user_id, &req.opaque_state, &req.credential) {
|
||||
Ok(_) => {
|
||||
users
|
||||
.send(users_actor::AddSuccessful2FALogin(user_id, remote_ip.0))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
SessionIdentity(Some(&id)).set_status(&http_req, SessionStatus::SignedIn);
|
||||
HttpResponse::Ok().body("You are authenticated!")
|
||||
}
|
||||
|
Reference in New Issue
Block a user