From 6466c0f6d7002ddba4f0dcb1dea70541b1ce9e30 Mon Sep 17 00:00:00 2001 From: Kumar Ankur Date: Mon, 13 Aug 2018 00:04:35 +0530 Subject: [PATCH] Changes to change email without email verification code (#110) --- src/api/core/accounts.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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(()) }