GRN-45: Fixed the URL being sent in the password reset email (#351)

* Fixed the url used in the reset password emails and added the ability to preview emails in the dev environment

* Replaced localhost with example.com in email previews

* Update password_reset.html.erb
This commit is contained in:
farhatahmad
2019-02-01 15:00:10 -05:00
committed by Jesus Federico
parent ecee282fc4
commit c73064a70a
4 changed files with 23 additions and 3 deletions

View File

@ -29,7 +29,7 @@ class PasswordResetsController < ApplicationController
@user = User.find_by(email: params[:password_reset][:email].downcase)
if @user
@user.create_reset_digest
@user.send_password_reset_email(request.base_url)
@user.send_password_reset_email(reset_link)
redirect_to root_url, notice: I18n.t("email_sent")
else
redirect_to new_password_reset_path, notice: I18n.t("no_user_email_exists")
@ -77,6 +77,10 @@ class PasswordResetsController < ApplicationController
end
end
def reset_link
request.base_url + edit_password_reset_path(@user.reset_token, email: @user.email)
end
# Confirms a valid user.
def valid_user
unless current_user&.email_verified && current_user.authenticated?(:reset, params[:id])