trust this device to skip 2fa (#9012)

* trust this device to skip 2fa

Signed-off-by: 21pages <sunboeasy@gmail.com>

* Update connection.rs

---------

Signed-off-by: 21pages <sunboeasy@gmail.com>
Co-authored-by: RustDesk <71636191+rustdesk@users.noreply.github.com>
This commit is contained in:
21pages
2024-08-12 18:08:33 +08:00
committed by GitHub
Unverified
parent 57834840b8
commit 1729ee337f
64 changed files with 845 additions and 22 deletions

View File

@@ -1156,15 +1156,29 @@ impl<T: InvokeUiSession> Session<T> {
self.send(Data::Login((os_username, os_password, password, remember)));
}
pub fn send2fa(&self, code: String) {
pub fn send2fa(&self, code: String, trust_this_device: bool) {
let mut msg_out = Message::new();
let hwid = if trust_this_device {
crate::get_hwid()
} else {
Bytes::new()
};
self.lc.write().unwrap().set_option(
"trust-this-device".to_string(),
if trust_this_device { "Y" } else { "" }.to_string(),
);
msg_out.set_auth_2fa(Auth2FA {
code,
hwid,
..Default::default()
});
self.send(Data::Message(msg_out));
}
pub fn get_enable_trusted_devices(&self) -> bool {
self.lc.read().unwrap().enable_trusted_devices
}
pub fn new_rdp(&self) {
self.send(Data::NewRDP);
}