// Verify checks whether the token in the URL is valid and activates either
// user's account or their new email address.
// If new email was changed and verified, an email will be sent to the old
// address about the change.
Verify checks whether the token in the URL is valid and activates either
user's account or their new email address.
If new email was changed and verified, an email will be sent to the old
address about the change.
// Verify checks whether the token in the URL is valid and activates either // user ' s account or their new email address . // If new email was changed and verified an email will be sent to the old // address about the change .
func (h *Handler) Verify(w http.ResponseWriter, r *http.Request) {
	usr, tok, err := h.FetchByToken(r)
	if err != nil {
		httpflow.RespondError(h.log, w, r, err)
		return
	}
	usrC := usr.ExposeCore()
	oEml := usrC.Email
	if err = usrC.Verify(tok); err != nil {
		httpflow.RespondError(h.log, w, r, err)
		return
	}
	ctx := r.Context()
	if err = h.db.UpdateUser(ctx, usr); err != nil {
		httpflow.RespondError(h.log, w, r, err)
		return
	}
	if oEml != usrC.Email { 
		go h.email.SendEmailChanged(ctx, oEml, usrC.Email)
	}
	httpflow.Respond(h.log, w, r, nil, http.StatusNoContent)
}
func ( h * Handler ) Verify ( w http . ResponseWriter , r * http . Request ) { usr , tok , err := h . FetchByToken ( r ) if err != nil { httpflow . RespondError ( h . log , w , r , err ) return } usrC := usr . ExposeCore ( ) oEml := usrC . Email if err = usrC . Verify ( tok ) ; err != nil { httpflow . RespondError ( h . log , w , r , err ) return } ctx := r . Context ( ) if err = h . db . UpdateUser ( ctx , usr ) ; err != nil { httpflow . RespondError ( h . log , w , r , err ) return } if oEml != usrC . Email { go h . email . SendEmailChanged ( ctx , oEml , usrC . Email ) } httpflow . Respond ( h . log , w , r , nil , http . StatusNoContent ) }
Verify checks whether the token in the URL is valid and activates either
user's account or their new email address.
Verify checks whether the token in the URL is valid and activates either user ' s account or their new email address .
// email was changed