refactor controller to avoid return

This commit is contained in:
simon lehericey 2021-10-11 11:30:45 +02:00
parent 5aaf46258a
commit 06dee2e023

View file

@ -13,14 +13,15 @@ class FranceConnect::ParticulierController < ApplicationController
fci = FranceConnectService.find_or_retrieve_france_connect_information(params[:code])
fci.associate_user!
if fci.user && !fci.user.can_france_connect?
user = fci.user
if user.can_france_connect?
connect_france_connect_particulier(user)
else
fci.destroy
redirect_to new_user_session_path, alert: t('errors.messages.france_connect.forbidden_html', reset_link: new_user_password_path)
return
end
connect_france_connect_particulier(fci.user)
rescue Rack::OAuth2::Client::Error => e
Rails.logger.error e.message
redirect_france_connect_error_connection