Merge factors type for authentication
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
use actix_identity::Identity;
|
||||
use actix_web::{HttpRequest, HttpResponse, Responder, web};
|
||||
use actix_web::{web, HttpRequest, HttpResponse, Responder};
|
||||
use webauthn_rs::prelude::PublicKeyCredential;
|
||||
|
||||
use crate::data::session_identity::{SessionIdentity, SessionStatus};
|
||||
@ -11,10 +11,12 @@ pub struct AuthWebauthnRequest {
|
||||
credential: PublicKeyCredential,
|
||||
}
|
||||
|
||||
pub async fn auth_webauthn(id: Identity,
|
||||
req: web::Json<AuthWebauthnRequest>,
|
||||
manager: WebAuthManagerReq,
|
||||
http_req: HttpRequest) -> impl Responder {
|
||||
pub async fn auth_webauthn(
|
||||
id: Identity,
|
||||
req: web::Json<AuthWebauthnRequest>,
|
||||
manager: WebAuthManagerReq,
|
||||
http_req: HttpRequest,
|
||||
) -> impl Responder {
|
||||
if !SessionIdentity(Some(&id)).need_2fa_auth() {
|
||||
return HttpResponse::Unauthorized().json("No 2FA required!");
|
||||
}
|
||||
@ -31,4 +33,4 @@ pub async fn auth_webauthn(id: Identity,
|
||||
HttpResponse::InternalServerError().body("Failed to validate security key!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user