forked from External/greenlight
		
	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:
		
				
					committed by
					
						
						Jesus Federico
					
				
			
			
				
	
			
			
			
						parent
						
							ecee282fc4
						
					
				
				
					commit
					c73064a70a
				
			@@ -29,7 +29,7 @@ class PasswordResetsController < ApplicationController
 | 
				
			|||||||
    @user = User.find_by(email: params[:password_reset][:email].downcase)
 | 
					    @user = User.find_by(email: params[:password_reset][:email].downcase)
 | 
				
			||||||
    if @user
 | 
					    if @user
 | 
				
			||||||
      @user.create_reset_digest
 | 
					      @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")
 | 
					      redirect_to root_url, notice: I18n.t("email_sent")
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      redirect_to new_password_reset_path, notice: I18n.t("no_user_email_exists")
 | 
					      redirect_to new_password_reset_path, notice: I18n.t("no_user_email_exists")
 | 
				
			||||||
@@ -77,6 +77,10 @@ class PasswordResetsController < ApplicationController
 | 
				
			|||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def reset_link
 | 
				
			||||||
 | 
					    request.base_url + edit_password_reset_path(@user.reset_token, email: @user.email)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # Confirms a valid user.
 | 
					  # Confirms a valid user.
 | 
				
			||||||
  def valid_user
 | 
					  def valid_user
 | 
				
			||||||
    unless current_user&.email_verified && current_user.authenticated?(:reset, params[:id])
 | 
					    unless current_user&.email_verified && current_user.authenticated?(:reset, params[:id])
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,7 +31,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      <a
 | 
					      <a
 | 
				
			||||||
        style="background: #467fcf;color: #ffffff; padding: 10px 15px; box-shadow: 0 2px 4px 0 rgba(0,0,0,.25);border: 1px solid transparent;text-decoration:none;"
 | 
					        style="background: #467fcf;color: #ffffff; padding: 10px 15px; box-shadow: 0 2px 4px 0 rgba(0,0,0,.25);border: 1px solid transparent;text-decoration:none;"
 | 
				
			||||||
        href="<%= edit_password_reset_url(@user.reset_token, email: @user.email, host: @url) %>">
 | 
					        href="<%= @url %>">
 | 
				
			||||||
        Reset Password
 | 
					        Reset Password
 | 
				
			||||||
      </a>
 | 
					      </a>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,7 @@ Password Reset
 | 
				
			|||||||
It seems like you forgot your password for <%= t('bigbluebutton') %>
 | 
					It seems like you forgot your password for <%= t('bigbluebutton') %>
 | 
				
			||||||
If this is true, please click the link below to reset your password:
 | 
					If this is true, please click the link below to reset your password:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<%= edit_password_reset_url(@user.reset_token,email: @user.email, host: @url) %>
 | 
					<%= @url %>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This link will expire in two hours.
 | 
					This link will expire in two hours.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,20 @@
 | 
				
			|||||||
# frozen_string_literal: true
 | 
					# frozen_string_literal: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class UserMailerPreview < ActionMailer::Preview
 | 
					class UserMailerPreview < ActionMailer::Preview
 | 
				
			||||||
 | 
					  # Preview this email at
 | 
				
			||||||
 | 
					  # http://localhost:3000/rails/mailers/user_mailer/password_reset
 | 
				
			||||||
 | 
					  def password_reset
 | 
				
			||||||
 | 
					    user = User.first
 | 
				
			||||||
 | 
					    user.reset_token = User.new_token
 | 
				
			||||||
 | 
					    url = "http://example.com" + "/password_resets/" + user.reset_token + "/edit?email=" + user.email
 | 
				
			||||||
 | 
					    UserMailer.password_reset(user, url)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  # Preview this email at
 | 
				
			||||||
 | 
					  # http://localhost:3000/rails/mailers/user_mailer/verify_email
 | 
				
			||||||
 | 
					  def verify_email
 | 
				
			||||||
 | 
					    user = User.first
 | 
				
			||||||
 | 
					    url = "http://example.com" + "/u/verify/confirm/" + user.uid
 | 
				
			||||||
 | 
					    UserMailer.verify_email(user, url)
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user