This commit is contained in:
Wenkai Yin 2017-03-30 13:51:56 +08:00 committed by kunw
parent 0d80608036
commit 052bc429a7

View File

@ -112,6 +112,13 @@ func (cc *CommonController) SendEmail() {
cc.CustomAbort(http.StatusNotFound, "email_does_not_exist")
}
uuid := utils.GenerateRandomString()
user := models.User{ResetUUID: uuid, Email: email}
if err = dao.UpdateUserResetUUID(user); err != nil {
log.Errorf("failed to update user reset UUID: %v", err)
cc.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
messageTemplate, err := template.ParseFiles("views/reset-password-mail.tpl")
if err != nil {
log.Errorf("Parse email template file failed: %v", err)
@ -126,7 +133,6 @@ func (cc *CommonController) SendEmail() {
cc.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
uuid := utils.GenerateRandomString()
err = messageTemplate.Execute(message, messageDetail{
Hint: cc.Tr("reset_email_hint"),
URL: harborURL,
@ -158,12 +164,6 @@ func (cc *CommonController) SendEmail() {
log.Errorf("Send email failed: %v", err)
cc.CustomAbort(http.StatusInternalServerError, "send_email_failed")
}
user := models.User{ResetUUID: uuid, Email: email}
if err = dao.UpdateUserResetUUID(user); err != nil {
log.Errorf("failed to update user reset UUID: %v", err)
cc.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
}
}
// ResetPassword handles request from the reset page and reset password