full 2fa flow pt2
This commit is contained in:
parent
5bdcac5e89
commit
2798d06c81
|
@ -39,7 +39,7 @@ pub struct VerifyTotpAuthenticatorResponse {
|
||||||
pub metadata: VerifyTotpAuthenticatorResponseMetadata,
|
pub metadata: VerifyTotpAuthenticatorResponseMetadata,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[options("/v1/auth/verify-totp-authenticator")]
|
#[options("/v1/verify-totp-authenticator")]
|
||||||
pub async fn options() -> &'static str {
|
pub async fn options() -> &'static str {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ pub async fn verify_totp_authenticator_request(req: Json<VerifyTotpAuthenticator
|
||||||
Err(e) => return Err((Status::Unauthorized, format!("{{\"errors\":[{{\"code\":\"{}\",\"message\":\"{} - {}\"}}]}}", "ERR_UNAUTHORIZED", "this token is invalid", e)))
|
Err(e) => return Err((Status::Unauthorized, format!("{{\"errors\":[{{\"code\":\"{}\",\"message\":\"{} - {}\"}}]}}", "ERR_UNAUTHORIZED", "this token is invalid", e)))
|
||||||
};
|
};
|
||||||
if !totpmachine.check_current(&req.0.code).unwrap() {
|
if !totpmachine.check_current(&req.0.code).unwrap() {
|
||||||
return Err((Status::Unauthorized, format!("{{\"errors\":[{{\"code\":\"{}\",\"message\":\"{}\",\"path\":\"totpToken\"}}]}}", "ERR_INVALID_TOTP_TOKEN", "TOTP token does not exist (maybe it expired?)")))
|
return Err((Status::Unauthorized, format!("{{\"errors\":[{{\"code\":\"{}\",\"message\":\"{}\",\"path\":\"totpToken\"}}]}}", "ERR_INVALID_TOTP_CODE", "Invalid TOTP code")))
|
||||||
}
|
}
|
||||||
match use_totp_token(req.0.totp_token, user.email, db.inner()).await {
|
match use_totp_token(req.0.totp_token, user.email, db.inner()).await {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
|
|
Loading…
Reference in New Issue