| @@ -234,7 +234,7 @@ func (email *EmailAddress) updateEmailAddress(e Engine, newEmailAddress string) | |||||
| if _, err := e.ID(email.ID).Cols("email").Update(email); err != nil { | if _, err := e.ID(email.ID).Cols("email").Update(email); err != nil { | ||||
| return err | return err | ||||
| } | } | ||||
| return updateUserCols(e, user, "email", "avartar_email") | |||||
| return updateUserCols(e, user, "email", "avatar_email") | |||||
| } | } | ||||
| // DeleteEmailAddress deletes an email address of given user. | // DeleteEmailAddress deletes an email address of given user. | ||||
| @@ -89,7 +89,7 @@ type RegisterForm struct { | |||||
| } | } | ||||
| type UpdateEmailForm struct { | type UpdateEmailForm struct { | ||||
| NewEmail string `binding:"Required;NewEmail;MaxSize(254)"` | |||||
| NewEmail string `binding:"Required;MaxSize(254)"` | |||||
| } | } | ||||
| // Validate valideates the fields | // Validate valideates the fields | ||||
| @@ -518,7 +518,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| // r.Get("/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds) | // r.Get("/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds) | ||||
| m.Any("/activate", user.Activate, reqSignIn) | m.Any("/activate", user.Activate, reqSignIn) | ||||
| m.Any("/activate_email", user.ActivateEmail) | m.Any("/activate_email", user.ActivateEmail) | ||||
| m.Post("/update_email", reqSignIn, bindIgnErr(auth.UpdateEmailForm{}), user.UpdateEmailPost) | |||||
| m.Post("/update_email", bindIgnErr(auth.UpdateEmailForm{}), user.UpdateEmailPost) | |||||
| m.Get("/avatar/:username/:size", user.Avatar) | m.Get("/avatar/:username/:size", user.Avatar) | ||||
| m.Get("/email2user", user.Email2User) | m.Get("/email2user", user.Email2User) | ||||
| m.Get("/recover_account", user.ResetPasswd) | m.Get("/recover_account", user.ResetPasswd) | ||||
| @@ -1415,9 +1415,13 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo | |||||
| //update user emailAddress | //update user emailAddress | ||||
| func UpdateEmailPost(ctx *context.Context, form auth.UpdateEmailForm) { | func UpdateEmailPost(ctx *context.Context, form auth.UpdateEmailForm) { | ||||
| newEmailAddress := form.NewEmail | |||||
| if used, err := models.IsEmailUsed(newEmailAddress); used { | |||||
| ctx.ServerError(ctx.Tr("form.email_been_used"), err) | |||||
| newEmailAddress := ctx.Query("NewEmail") | |||||
| if newEmailAddress == "" { | |||||
| log.Error("please input the newEmail") | |||||
| return | |||||
| } | |||||
| if used, _ := models.IsEmailUsed(newEmailAddress); used { | |||||
| ctx.RenderWithErr(ctx.Tr("form.email_been_used"), TplActivate, &form) | |||||
| return | return | ||||
| } | } | ||||
| user := ctx.User | user := ctx.User | ||||
| @@ -1431,7 +1435,10 @@ func UpdateEmailPost(ctx *context.Context, form auth.UpdateEmailForm) { | |||||
| ctx.ServerError("UpdateEmailAddress failed", err) | ctx.ServerError("UpdateEmailAddress failed", err) | ||||
| return | return | ||||
| } | } | ||||
| ctx.Data["Email"] = newEmailAddress | |||||
| ctx.User.Email = newEmailAddress | |||||
| Activate(ctx) | Activate(ctx) | ||||
| } | } | ||||
| // Activate render activate user page | // Activate render activate user page | ||||
| @@ -15,7 +15,7 @@ | |||||
| {{else if .ResendLimited}} | {{else if .ResendLimited}} | ||||
| <p class="center">{{.i18n.Tr "auth.resent_limit_prompt"}}</p> | <p class="center">{{.i18n.Tr "auth.resent_limit_prompt"}}</p> | ||||
| {{else}} | {{else}} | ||||
| <p>{{.i18n.Tr "auth.confirmation_mail_sent_prompt" .SignedUser.Email .ActiveCodeLives | Str2html}}</p> | |||||
| <p>{{.i18n.Tr "auth.confirmation_mail_sent_prompt" .Email .ActiveCodeLives | Str2html}}</p> | |||||
| {{end}} | {{end}} | ||||
| {{else}} | {{else}} | ||||
| {{if .IsSendRegisterMail}} | {{if .IsSendRegisterMail}} | ||||