improve tfa

This commit is contained in:
rustdesk 2024-03-20 20:00:29 +08:00
parent 8b9728b40b
commit 21e4679b6c
2 changed files with 3 additions and 4 deletions

View File

@ -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")))]

View File

@ -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;