parent
d05bab3df3
commit
6b27ac8514
2 changed files with 12 additions and 1 deletions
|
@ -13,7 +13,7 @@ class FranceConnect::ParticulierController < ApplicationController
|
|||
fetched_fci.tap(&:save)
|
||||
|
||||
if fci.user.nil?
|
||||
user = User.find_or_create_by(email: fci.email_france_connect) do |new_user|
|
||||
user = User.find_or_create_by(email: fci.email_france_connect.downcase) do |new_user|
|
||||
new_user.password = Devise.friendly_token[0, 20]
|
||||
new_user.confirmed_at = Time.zone.now
|
||||
end
|
||||
|
|
|
@ -85,6 +85,17 @@ describe FranceConnect::ParticulierController, type: :controller do
|
|||
expect(subject).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a differently cased email address is already used' do
|
||||
let(:email) { 'TEST@test.com' }
|
||||
let!(:user) { create(:user, email: email.downcase, france_connect_information: nil) }
|
||||
|
||||
it 'associates the france_connect infos with the existing user' do
|
||||
expect { subject }.not_to change(User, :count)
|
||||
expect(user.reload.loged_in_with_france_connect).to eq(User.loged_in_with_france_connects.fetch(:particulier))
|
||||
expect(subject).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue