mirror of
https://github.com/dani-garcia/vaultwarden.wiki.git
synced 2026-11-05 06:28:36 +02:00
Improved two factor auth
This commit is contained in:
1 parent
dc188211d8
commit
b0ee5f6570
8 files changed
+251
-107
No files matched your search
@@ -19,6 +19,8 @@ pub struct Device {
|
||||
pub push_token: Option<String>,
|
||||
|
||||
pub refresh_token: String,
|
||||
|
||||
pub twofactor_remember: Option<String>,
|
||||
}
|
||||
|
||||
/// Local methods
|
||||
@@ -37,9 +39,22 @@ impl Device {
|
||||
|
||||
push_token: None,
|
||||
refresh_token: String::new(),
|
||||
twofactor_remember: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn refresh_twofactor_remember(&mut self) {
|
||||
use data_encoding::BASE64;
|
||||
use crypto;
|
||||
|
||||
self.twofactor_remember = Some(BASE64.encode(&crypto::get_random(vec![0u8; 180])));
|
||||
}
|
||||
|
||||
pub fn delete_twofactor_remember(&mut self) {
|
||||
self.twofactor_remember = None;
|
||||
}
|
||||
|
||||
|
||||
pub fn refresh_tokens(&mut self, user: &super::User, orgs: Vec<super::UserOrganization>) -> (String, i64) {
|
||||
// If there is no refresh token, we create one
|
||||
if self.refresh_token.is_empty() {
|
||||
|
||||
Reference in new issue
Block a user