Do not raise error if user is nil
I do not get when it happens
This commit is contained in:
parent
2248b76d09
commit
f54dfe6ead
2 changed files with 12 additions and 1 deletions
|
@ -45,7 +45,7 @@ class FranceConnect::ParticulierController < ApplicationController
|
|||
def merge_with_existing_account
|
||||
user = User.find_by(email: sanitized_email_params)
|
||||
|
||||
if user.valid_for_authentication? { user.valid_password?(password_params) }
|
||||
if user.present? && user.valid_for_authentication? { user.valid_password?(password_params) }
|
||||
if !user.can_france_connect?
|
||||
flash.alert = "#{user.email} ne peut utiliser FranceConnect"
|
||||
|
||||
|
|
|
@ -189,6 +189,17 @@ describe FranceConnect::ParticulierController, type: :controller do
|
|||
|
||||
it_behaves_like "a method that needs a valid merge token"
|
||||
|
||||
context 'when the user is not found' do
|
||||
it 'does not log' do
|
||||
subject
|
||||
fci.reload
|
||||
|
||||
expect(fci.user).to be_nil
|
||||
expect(fci.merge_token).not_to be_nil
|
||||
expect(controller.current_user).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the credentials are ok' do
|
||||
let!(:user) { create(:user, email: email, password: password) }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue