From 9109f68c968b5e18e6fb74ff106289640ac1b4e0 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 10 May 2017 23:43:58 +0200 Subject: [PATCH] Make Email changes work correctly --- router/userHandler.go | 12 +++++++----- translations/de-de.all.json | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/router/userHandler.go b/router/userHandler.go index 7f72a9b3..277e2858 100755 --- a/router/userHandler.go +++ b/router/userHandler.go @@ -140,6 +140,7 @@ func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) { if len(r.PostFormValue("username")) > 0 { _, err = form.ValidateUsername(r.PostFormValue("username"), err) } + if len(err) == 0 { modelHelper.BindValueForm(&b, r) if (!userPermission.HasAdmin(currentUser)) { @@ -147,15 +148,16 @@ func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) { } err = modelHelper.ValidateForm(&b, err) if len(err) == 0 { + if (b.Email != currentUser.Email) { + userService.SendVerificationToUser(*currentUser, b.Email) + infos["infos"] = append(infos["infos"], fmt.Sprintf(T("email_changed"), b.Email)) + b.Email = currentUser.Email // reset, it will be set when user clicks verification + } userProfile, _, errorUser = userService.UpdateUser(w, &b, currentUser, id) if errorUser != nil { err["errors"] = append(err["errors"], errorUser.Error()) - } - if len(err) == 0 { + } else { infos["infos"] = append(infos["infos"], T("profile_updated")) - if (b.Email != currentUser.Email) { - infos["infos"] = append(infos["infos"], fmt.Sprintf(T("email_changed"), b.Email)) - } } } } diff --git a/translations/de-de.all.json b/translations/de-de.all.json index acab19b2..da4a3ddf 100644 --- a/translations/de-de.all.json +++ b/translations/de-de.all.json @@ -570,5 +570,9 @@ { "id": "mark_as_remake", "translation": "Als Remake markieren" + }, + { + "id": "email_changed", + "translation": "E-Mail erfolgreich geändert! Bitte bestätige die Änderung mit dem Bestätigung-Link (an %s gesendet)" } ]