0
0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden synced 2024-12-14 17:43:46 +01:00

Merge branch 'BlackDex-fix-password-hint'

This commit is contained in:
Daniel García 2022-10-19 20:40:24 +02:00
commit bbc6470f65
No known key found for this signature in database
GPG key ID: FC8A7D14C3CD543A

View file

@ -189,9 +189,8 @@ async fn profile(headers: Headers, conn: DbConn) -> Json<Value> {
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
#[allow(non_snake_case)] #[allow(non_snake_case)]
struct ProfileData { struct ProfileData {
#[serde(rename = "Culture")] // Culture: String, // Ignored, always use en-US
_Culture: String, // Ignored, always use en-US // MasterPasswordHint: Option<String>, // Ignored, has been moved to ChangePassData
MasterPasswordHint: Option<String>,
Name: String, Name: String,
} }
@ -212,8 +211,6 @@ async fn post_profile(data: JsonUpcase<ProfileData>, headers: Headers, conn: DbC
let mut user = headers.user; let mut user = headers.user;
user.name = data.Name; user.name = data.Name;
user.password_hint = clean_password_hint(&data.MasterPasswordHint);
enforce_password_hint_setting(&user.password_hint)?;
user.save(&conn).await?; user.save(&conn).await?;
Ok(Json(user.to_json(&conn).await)) Ok(Json(user.to_json(&conn).await))
@ -256,6 +253,7 @@ async fn post_keys(data: JsonUpcase<KeysData>, headers: Headers, conn: DbConn) -
struct ChangePassData { struct ChangePassData {
MasterPasswordHash: String, MasterPasswordHash: String,
NewMasterPasswordHash: String, NewMasterPasswordHash: String,
MasterPasswordHint: Option<String>,
Key: String, Key: String,
} }
@ -268,6 +266,9 @@ async fn post_password(data: JsonUpcase<ChangePassData>, headers: Headers, conn:
err!("Invalid password") err!("Invalid password")
} }
user.password_hint = clean_password_hint(&data.MasterPasswordHint);
enforce_password_hint_setting(&user.password_hint)?;
user.set_password( user.set_password(
&data.NewMasterPasswordHash, &data.NewMasterPasswordHash,
Some(vec![String::from("post_rotatekey"), String::from("get_contacts"), String::from("get_public_keys")]), Some(vec![String::from("post_rotatekey"), String::from("get_contacts"), String::from("get_public_keys")]),