Merge pull request #5456 from 21pages/ab

always sync recent/ab password
This commit is contained in:
RustDesk
2023-08-21 10:50:08 +08:00
committed by GitHub
6 changed files with 42 additions and 16 deletions

View File

@@ -1074,7 +1074,7 @@ pub struct LoginConfigHandler {
pub direct: Option<bool>,
pub received: bool,
switch_uuid: Option<String>,
pub save_ab_password_to_recent: bool,
pub save_ab_password_to_recent: bool, // true: connected with ab password
}
impl Deref for LoginConfigHandler {
@@ -1656,6 +1656,18 @@ impl LoginConfigHandler {
log::debug!("remove password of {}", self.id);
}
}
#[cfg(feature = "flutter")]
{
// sync ab password with PeerConfig password
let password = base64::encode(config.password.clone(), base64::Variant::Original);
let evt: HashMap<&str, String> = HashMap::from([
("name", "sync_peer_password_to_ab".to_string()),
("id", self.id.clone()),
("password", password),
]);
let evt = serde_json::ser::to_string(&evt).unwrap_or("".to_owned());
crate::flutter::push_global_event(crate::flutter::APP_TYPE_MAIN, evt);
}
if config.keyboard_mode.is_empty() {
if is_keyboard_mode_supported(&KeyboardMode::Map, get_version_number(&pi.version)) {
config.keyboard_mode = KeyboardMode::Map.to_string();
@@ -2260,12 +2272,12 @@ pub async fn handle_hash(
if !hash.is_empty() {
password = hash;
lc.write().unwrap().save_ab_password_to_recent = true;
lc.write().unwrap().password = password.clone();
}
}
}
}
}
lc.write().unwrap().password = password.clone();
let password = if password.is_empty() {
// login without password, the remote side can click accept
interface.msgbox("input-password", "Password Required", "", "");
@@ -2337,9 +2349,9 @@ pub async fn handle_login_from_ui(
hasher.update(&lc.read().unwrap().hash.salt);
let res = hasher.finalize();
lc.write().unwrap().remember = remember;
lc.write().unwrap().password = res[..].into();
res[..].into()
};
lc.write().unwrap().password = hash_password.clone();
let mut hasher2 = Sha256::new();
hasher2.update(&hash_password[..]);
hasher2.update(&lc.read().unwrap().hash.challenge);