Merge pull request #6555 from betagouv/fix_fc
FC ne lève pas d'exception lorsque le merge concerne un compte qui n'existe pas
This commit is contained in:
commit
98107eb7da
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…
Reference in a new issue