emails: send verification mail when user changes address.

This commit is contained in:
evazion
2020-03-14 18:32:00 -05:00
parent 167fe51a8a
commit d860fab7f5
7 changed files with 61 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ class EmailsController < ApplicationController
if @user.errors.none?
flash[:notice] = "Email updated"
UserMailer.email_change_confirmation(@user).deliver_later
respond_with(@user, location: settings_url)
else
flash[:notice] = @user.errors.full_messages.join("; ")
@@ -28,6 +29,15 @@ class EmailsController < ApplicationController
end
end
def verify
email_id = Danbooru::MessageVerifier.new(:email_verification_key).verify(params[:email_verification_key])
@email_address = EmailAddress.find(email_id)
@email_address.update!(is_verified: true)
flash[:notice] = "Email address verified"
redirect_to @email_address.user
end
private
def check_privilege(user)