- def confirm_email
- if request.post?
- token = UserToken.find_by(:token => params[:confirm_string])
- if token&.user&.new_email?
- self.current_user = token.user
- current_user.email = current_user.new_email
- current_user.new_email = nil
- current_user.email_valid = true
- gravatar_enabled = gravatar_enable(current_user)
- if current_user.save
- flash[:notice] = if gravatar_enabled
- "#{t('users.confirm_email.success')} #{gravatar_status_message(current_user)}"
- else
- t("users.confirm_email.success")
- end
- else
- flash[:errors] = current_user.errors
- end
- current_user.tokens.delete_all
- session[:user] = current_user.id
- session[:fingerprint] = current_user.fingerprint
- redirect_to :action => "account", :display_name => current_user.display_name
- elsif token
- flash[:error] = t "users.confirm_email.failure"
- redirect_to :action => "account", :display_name => token.user.display_name
+ referer = safe_referer(params[:referer]) if params[:referer]
+
+ redirect_to referer || edit_account_path
+ elsif params[:decline]
+ redirect_to t("users.terms.declined"), :allow_other_host => true