diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs index fe26c4d4..18db8b16 100644 --- a/src/api/core/accounts.rs +++ b/src/api/core/accounts.rs @@ -163,8 +163,9 @@ struct EmailTokenData { #[post("/accounts/email-token", data = "")] fn post_email_token(data: JsonUpcase, headers: Headers, conn: DbConn) -> EmptyResult { let data: EmailTokenData = data.into_inner().data; + let mut user = headers.user; - if !headers.user.check_valid_password(&data.MasterPasswordHash) { + if !user.check_valid_password(&data.MasterPasswordHash) { err!("Invalid password") } @@ -172,6 +173,10 @@ fn post_email_token(data: JsonUpcase, headers: Headers, conn: Db err!("Email already in use"); } + user.email = data.NewEmail; + + user.save(&conn); + Ok(()) }