Fixed 404 when resending verification email (#2110)

This commit is contained in:
Ahmad Farhat 2020-09-21 15:32:05 -04:00 committed by GitHub
parent 360783606e
commit 816cefe1b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -20,8 +20,7 @@ class AccountActivationsController < ApplicationController
include Emailer
before_action :ensure_unauthenticated
before_action :find_user, except: :show
before_action :find_user_by_digest, only: :show
before_action :find_user
# GET /account_activations
def show
@ -45,7 +44,7 @@ class AccountActivationsController < ApplicationController
end
end
# GET /account_activations/resend
# POST /account_activations/resend
def resend
if @user.activated?
# User is already verified
@ -61,11 +60,15 @@ class AccountActivationsController < ApplicationController
private
def find_user
@user = User.find_by!(activation_digest: User.hash_token(params[:token]), provider: @user_domain)
digest = if params[:token].present?
User.hash_token(params[:token])
elsif params[:digest].present?
params[:digest]
else
raise "Missing token/digest params"
end
def find_user_by_digest
@user = User.find_by!(activation_digest: params[:digest], provider: @user_domain)
@user = User.find_by!(activation_digest: digest, provider: @user_domain)
end
def ensure_unauthenticated

View File

@ -22,7 +22,7 @@
<div class="card-body">
<p><%= t("verify.not_verified") %></p>
<div class="btn-list text-right pt-8">
<%= button_to t("verify.resend"), resend_email_path, params: { token: params['token'], email_verified: false }, class: "btn btn-primary btn-space", "data-disable": "" %>
<%= button_to t("verify.resend"), resend_email_path, params: { digest: params[:digest], email_verified: false }, class: "btn btn-primary btn-space", "data-disable": "" %>
</div>
</div>
</div>