fix and finish totp authenticators
This commit is contained in:
parent
f0e36b3031
commit
eb60011ebd
|
@ -1,6 +1,6 @@
|
|||
use actix_web::{HttpRequest, HttpResponse, post};
|
||||
use actix_web::web::{Data, Json};
|
||||
use log::error;
|
||||
use log::{debug, error};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use trifid_api_entities::entity::totp_authenticator;
|
||||
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,
|
||||
Err(e) => {
|
||||
error!("system time error: {}", e);
|
||||
|
@ -137,6 +139,7 @@ pub async fn verify_totp_authenticators_request(req: Json<VerifyTotpAuthenticato
|
|||
};
|
||||
|
||||
if !valid {
|
||||
debug!("current: {}", totpmachine.generate_current().unwrap());
|
||||
error!("user send invalid totp code");
|
||||
return HttpResponse::Unauthorized().json(APIErrorsResponse {
|
||||
errors: vec![
|
||||
|
|
Loading…
Reference in New Issue