diff options
Diffstat (limited to 'web/web.go')
-rw-r--r-- | web/web.go | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/web/web.go b/web/web.go index a1bbf5a81..87c96659d 100644 --- a/web/web.go +++ b/web/web.go @@ -414,7 +414,12 @@ func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) { return } else { user := result.Data.(*model.User) - api.FireAndForgetVerifyEmail(user.Id, user.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team)) + + if user.LastActivityAt > 0 { + api.FireAndForgetEmailChangeVerifyEmail(user.Id, user.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team)) + } else { + api.FireAndForgetVerifyEmail(user.Id, user.Email, team.Name, team.DisplayName, c.GetSiteURL(), c.GetTeamURLFromTeam(team)) + } newAddress := strings.Replace(r.URL.String(), "&resend=true", "&resend_success=true", -1) http.Redirect(w, r, newAddress, http.StatusFound) @@ -422,24 +427,17 @@ func verifyEmail(c *api.Context, w http.ResponseWriter, r *http.Request) { } } - var isVerified string - if len(userId) != 26 { - isVerified = "false" - } else if len(hashedId) == 0 { - isVerified = "false" - } else if model.ComparePassword(hashedId, userId) { - isVerified = "true" + if len(userId) == 26 && len(hashedId) != 0 && model.ComparePassword(hashedId, userId) { if c.Err = (<-api.Srv.Store.User().VerifyEmail(userId)).Err; c.Err != nil { return } else { - c.LogAudit("") + c.LogAudit("Email Verified") + http.Redirect(w, r, api.GetProtocol(r)+"://"+r.Host+"/"+name+"/login?verified=true&email="+email, http.StatusTemporaryRedirect) + return } - } else { - isVerified = "false" } page := NewHtmlTemplatePage("verify", "Email Verified") - page.Props["IsVerified"] = isVerified page.Props["TeamURL"] = c.GetTeamURLFromTeam(team) page.Props["UserEmail"] = email page.Props["ResendSuccess"] = resendSuccess |