mirror of
https://github.com/rustdesk/hbb_common.git
synced 2025-07-01 23:47:24 +00:00
Merge pull request #178 from fufesou/fix/numeric_one_time_password
fix: numeric one-time password on startup
This commit is contained in:
commit
15a71f07a5
@ -3,7 +3,7 @@ use sodiumoxide::base64;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref TEMPORARY_PASSWORD:Arc<RwLock<String>> = Arc::new(RwLock::new(Config::get_auto_password(temporary_password_length())));
|
||||
pub static ref TEMPORARY_PASSWORD:Arc<RwLock<String>> = Arc::new(RwLock::new(get_auto_password()));
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@ -20,14 +20,18 @@ pub enum ApproveMode {
|
||||
Click,
|
||||
}
|
||||
|
||||
fn get_auto_password() -> String {
|
||||
let len = temporary_password_length();
|
||||
if Config::get_bool_option(crate::config::keys::OPTION_ALLOW_NUMERNIC_ONE_TIME_PASSWORD) {
|
||||
Config::get_auto_numeric_password(len)
|
||||
} else {
|
||||
Config::get_auto_password(len)
|
||||
}
|
||||
}
|
||||
|
||||
// Should only be called in server
|
||||
pub fn update_temporary_password() {
|
||||
*TEMPORARY_PASSWORD.write().unwrap() =
|
||||
if Config::get_bool_option(crate::config::keys::OPTION_ALLOW_NUMERNIC_ONE_TIME_PASSWORD) {
|
||||
Config::get_auto_numeric_password(temporary_password_length())
|
||||
} else {
|
||||
Config::get_auto_password(temporary_password_length())
|
||||
};
|
||||
*TEMPORARY_PASSWORD.write().unwrap() = get_auto_password();
|
||||
}
|
||||
|
||||
// Should only be called in server
|
||||
|
Loading…
x
Reference in New Issue
Block a user