fix and finish totp authenticators

This commit is contained in:
c0repwn3r 2023-04-03 08:41:47 -04:00
parent f0e36b3031
commit eb60011ebd
Signed by: core
GPG Key ID: FDBF740DADDCEECF
1 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,6 @@
use actix_web::{HttpRequest, HttpResponse, post}; use actix_web::{HttpRequest, HttpResponse, post};
use actix_web::web::{Data, Json}; use actix_web::web::{Data, Json};
use log::error; use log::{debug, error};
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use trifid_api_entities::entity::totp_authenticator; use trifid_api_entities::entity::totp_authenticator;
use crate::AppState; use crate::AppState;
@ -120,7 +120,9 @@ pub async fn verify_totp_authenticators_request(req: Json<VerifyTotpAuthenticato
}); });
} }
}; };
let valid = match totpmachine.check_current(&req.totp_token) {
let valid = match totpmachine.check_current(&req.code) {
Ok(valid) => valid, Ok(valid) => valid,
Err(e) => { Err(e) => {
error!("system time error: {}", e); error!("system time error: {}", e);
@ -137,6 +139,7 @@ pub async fn verify_totp_authenticators_request(req: Json<VerifyTotpAuthenticato
}; };
if !valid { if !valid {
debug!("current: {}", totpmachine.generate_current().unwrap());
error!("user send invalid totp code"); error!("user send invalid totp code");
return HttpResponse::Unauthorized().json(APIErrorsResponse { return HttpResponse::Unauthorized().json(APIErrorsResponse {
errors: vec![ errors: vec![