Fix #4571: Show banner when email verification is required.

* Show a banner if the user is restricted because they signed up from a
  proxy or VPN.

* Add an option to resend the confirmation email if your account has an
  unverified email address.
This commit is contained in:
evazion
2020-08-02 16:32:49 -05:00
parent a8577b2b94
commit baf0cf87af
11 changed files with 173 additions and 22 deletions

View File

@@ -21,7 +21,7 @@ class EmailsController < ApplicationController
end
if @user.errors.none?
flash[:notice] = "Email updated"
flash[:notice] = "Email updated. Check your email to confirm your new address"
UserMailer.email_change_confirmation(@user).deliver_later
respond_with(@user, location: settings_url)
else
@@ -31,10 +31,27 @@ class EmailsController < ApplicationController
end
def verify
@email_address = authorize EmailAddress.find_by_user_id!(params[:user_id])
@email_address.update!(is_verified: true)
@user = User.find(params[:user_id])
@email_address = @user.email_address
flash[:notice] = "Email address verified"
redirect_to @email_address.user
if @email_address.blank?
redirect_to edit_user_email_path(@user)
elsif params[:email_verification_key].present?
authorize @email_address
@email_address.update!(is_verified: true)
flash[:notice] = "Email address verified"
redirect_to @email_address.user
else
authorize @email_address
respond_with(@user)
end
end
def send_confirmation
@user = authorize User.find(params[:user_id]), policy_class: EmailAddressPolicy
UserMailer.welcome_user(@user).deliver_later
flash[:notice] = "Confirmation email sent to #{@user.email_address.address}. Check your email to confirm your address"
redirect_to @user
end
end