fix: encode reset link email in param because it's rendered in view later
This commit is contained in:
parent
9db7b5b864
commit
0a07c9cd72
3 changed files with 12 additions and 5 deletions
|
@ -286,7 +286,8 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
send_login_token_or_bufferize(current_instructeur)
|
||||
redirect_to link_sent_path(email: current_instructeur.email)
|
||||
signed_email = message_verifier.generate(current_instructeur.email, purpose: :reset_link, expires_in: 1.hour)
|
||||
redirect_to link_sent_path(email: signed_email)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -25,12 +25,16 @@ class Users::SessionsController < Devise::SessionsController
|
|||
if send_login_token_or_bufferize(current_instructeur)
|
||||
flash[:notice] = "Nous venons de vous renvoyer un nouveau lien de connexion sécurisée à #{APPLICATION_NAME}"
|
||||
end
|
||||
redirect_to link_sent_path(email: current_instructeur.email)
|
||||
|
||||
signed_email = message_verifier.generate(current_instructeur.email, purpose: :reset_link, expires_in: 1.hour)
|
||||
redirect_to link_sent_path(email: signed_email)
|
||||
end
|
||||
|
||||
def link_sent
|
||||
if StrictEmailValidator::REGEXP.match?(params[:email])
|
||||
@email = params[:email]
|
||||
email = message_verifier.verify(params[:email], purpose: :reset_link) rescue nil
|
||||
|
||||
if StrictEmailValidator::REGEXP.match?(email)
|
||||
@email = email
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
|
|
|
@ -225,7 +225,9 @@ describe Users::SessionsController, type: :controller do
|
|||
describe '#link_sent' do
|
||||
render_views
|
||||
|
||||
before { get :link_sent, params: { email: link_email } }
|
||||
before { get :link_sent, params: { email: signed_email } }
|
||||
|
||||
let(:signed_email) { controller.message_verifier.generate(link_email, purpose: :reset_link) }
|
||||
|
||||
context 'when the email is legit' do
|
||||
let(:link_email) { 'a@a.com' }
|
||||
|
|
Loading…
Reference in a new issue