include key into user.set_password

This commit is contained in:
sirux88
2023-01-14 10:16:03 +01:00
committed by Daniel García
parent 34ac16e9d7
commit d121cce0d2
3 changed files with 11 additions and 12 deletions

View File

@@ -161,8 +161,7 @@ pub async fn _register(data: JsonUpcase<RegisterData>, mut conn: DbConn) -> Json
user.client_kdf_type = client_kdf_type;
}
user.set_password(&data.MasterPasswordHash, None);
user.akey = data.Key;
user.set_password(&data.MasterPasswordHash, &data.Key, None);
user.password_hint = password_hint;
// Add extra fields if present
@@ -318,9 +317,10 @@ async fn post_password(
user.set_password(
&data.NewMasterPasswordHash,
&data.Key,
Some(vec![String::from("post_rotatekey"), String::from("get_contacts"), String::from("get_public_keys")]),
);
user.akey = data.Key;
let save_result = user.save(&mut conn).await;
// Prevent loging out the client where the user requested this endpoint from.
@@ -353,8 +353,7 @@ async fn post_kdf(data: JsonUpcase<ChangeKdfData>, headers: Headers, mut conn: D
user.client_kdf_iter = data.KdfIterations;
user.client_kdf_type = data.Kdf;
user.set_password(&data.NewMasterPasswordHash, None);
user.akey = data.Key;
user.set_password(&data.NewMasterPasswordHash, &data.Key, None);
let save_result = user.save(&mut conn).await;
nt.send_logout(&user, Some(headers.device.uuid)).await;
@@ -572,8 +571,8 @@ async fn post_email(
user.email_new = None;
user.email_new_token = None;
user.set_password(&data.NewMasterPasswordHash, None);
user.akey = data.Key;
user.set_password(&data.NewMasterPasswordHash, &data.Key, None);
let save_result = user.save(&mut conn).await;
nt.send_logout(&user, None).await;