feat(particulier#associate_user): catch email already taken and redirect to reset password

This commit is contained in:
mfo 2024-07-24 16:36:16 +02:00 committed by Kara Diaby
parent 828f491c14
commit 88a4619dcb
No known key found for this signature in database
GPG key ID: C4D1B0CF9F24D759
4 changed files with 32 additions and 0 deletions

View file

@ -58,6 +58,12 @@ class FranceConnect::ParticulierController < ApplicationController
destination_path = destination_path(user)
render :confirmation_sent, locals: { email:, destination_path: }
rescue ActiveRecord::RecordInvalid => e
if e.record.errors.where(:email, :taken)
redirect_to new_user_session_path, alert: t('errors.messages.france_connect.email_taken', reset_link: new_user_password_path)
else
redirect_to new_user_session_path, alert: t('errors.messages.france_connect.unknown_error')
end
end
def merge