This commit is contained in:
@ -1,5 +1,5 @@
|
||||
use actix_identity::Identity;
|
||||
use actix_web::{HttpResponse, Responder, web};
|
||||
use actix_web::{HttpRequest, HttpResponse, Responder, web};
|
||||
use webauthn_rs::proto::PublicKeyCredential;
|
||||
|
||||
use crate::data::session_identity::{SessionIdentity, SessionStatus};
|
||||
@ -13,16 +13,17 @@ pub struct AuthWebauthnRequest {
|
||||
|
||||
pub async fn auth_webauthn(id: Identity,
|
||||
req: web::Json<AuthWebauthnRequest>,
|
||||
manager: WebAuthManagerReq) -> impl Responder {
|
||||
if !SessionIdentity(&id).need_2fa_auth() {
|
||||
manager: WebAuthManagerReq,
|
||||
http_req: HttpRequest) -> impl Responder {
|
||||
if !SessionIdentity(Some(&id)).need_2fa_auth() {
|
||||
return HttpResponse::Unauthorized().json("No 2FA required!");
|
||||
}
|
||||
|
||||
let user_id = SessionIdentity(&id).user_id();
|
||||
let user_id = SessionIdentity(Some(&id)).user_id();
|
||||
|
||||
match manager.finish_authentication(&user_id, &req.opaque_state, &req.credential) {
|
||||
Ok(_) => {
|
||||
SessionIdentity(&id).set_status(SessionStatus::SignedIn);
|
||||
SessionIdentity(Some(&id)).set_status(&http_req, SessionStatus::SignedIn);
|
||||
HttpResponse::Ok().body("You are authenticated!")
|
||||
}
|
||||
Err(e) => {
|
||||
|
Reference in New Issue
Block a user