Make Email changes work correctly
Cette révision appartient à :
Parent
40b3fddc24
révision
9109f68c96
2 fichiers modifiés avec 11 ajouts et 5 suppressions
|
@ -140,6 +140,7 @@ func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if len(r.PostFormValue("username")) > 0 {
|
if len(r.PostFormValue("username")) > 0 {
|
||||||
_, err = form.ValidateUsername(r.PostFormValue("username"), err)
|
_, err = form.ValidateUsername(r.PostFormValue("username"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(err) == 0 {
|
if len(err) == 0 {
|
||||||
modelHelper.BindValueForm(&b, r)
|
modelHelper.BindValueForm(&b, r)
|
||||||
if (!userPermission.HasAdmin(currentUser)) {
|
if (!userPermission.HasAdmin(currentUser)) {
|
||||||
|
@ -147,15 +148,16 @@ func UserProfileFormHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
err = modelHelper.ValidateForm(&b, err)
|
err = modelHelper.ValidateForm(&b, err)
|
||||||
if len(err) == 0 {
|
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)
|
userProfile, _, errorUser = userService.UpdateUser(w, &b, currentUser, id)
|
||||||
if errorUser != nil {
|
if errorUser != nil {
|
||||||
err["errors"] = append(err["errors"], errorUser.Error())
|
err["errors"] = append(err["errors"], errorUser.Error())
|
||||||
}
|
} else {
|
||||||
if len(err) == 0 {
|
|
||||||
infos["infos"] = append(infos["infos"], T("profile_updated"))
|
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))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -570,5 +570,9 @@
|
||||||
{
|
{
|
||||||
"id": "mark_as_remake",
|
"id": "mark_as_remake",
|
||||||
"translation": "Als Remake markieren"
|
"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)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Référencer dans un nouveau ticket