1
0
Fork 1
Spiegel von https://github.com/dani-garcia/vaultwarden.git synchronisiert 2024-11-29 06:20:29 +01:00

Fix master password hint update not working.

- The Master Password Hint input has changed it's location to the
password update form. This PR updates the the code to process this.

- Also changed the `ProfileData` struct to exclude `Culture` and
`MasterPasswordHint`, since both are not used at all, and when not
defined they will also not be allocated.

Fixes #2833
Dieser Commit ist enthalten in:
BlackDex 2022-10-17 17:23:21 +02:00
Ursprung 638766b346
Commit f41ba2a60f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 58C80A2AA6C765E1

Datei anzeigen

@ -193,9 +193,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,
} }
@ -216,8 +215,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))
@ -260,6 +257,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,
} }
@ -272,6 +270,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")]),