improve tfa
This commit is contained in:
parent
8b9728b40b
commit
21e4679b6c
@ -89,8 +89,7 @@ pub fn generate2fa() -> String {
|
||||
|
||||
pub fn verify2fa(code: String) -> bool {
|
||||
if let Some((info, totp)) = CURRENT_2FA.lock().unwrap().as_ref() {
|
||||
if let Ok(cur) = totp.generate_current() {
|
||||
let res = code == cur;
|
||||
if let Ok(res) = totp.check_current(&code) {
|
||||
if res {
|
||||
if let Ok(v) = info.into_string() {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
|
@ -1750,8 +1750,8 @@ impl Connection {
|
||||
return true;
|
||||
}
|
||||
if let Some(totp) = self.require_2fa.as_ref() {
|
||||
if let Ok(code) = totp.generate_current() {
|
||||
if tfa.code == code {
|
||||
if let Ok(res) = totp.check_current(&tfa.code) {
|
||||
if res {
|
||||
self.update_failure(failure, true, 1);
|
||||
self.require_2fa.take();
|
||||
self.send_logon_response().await;
|
||||
|
Loading…
Reference in New Issue
Block a user