FC ParticulierController: callback syntax cleaning
This commit is contained in:
parent
4294c8eec7
commit
e68fc0811f
1 changed files with 12 additions and 6 deletions
|
@ -4,13 +4,16 @@ class FranceConnect::ParticulierController < ApplicationController
|
|||
end
|
||||
|
||||
def callback
|
||||
return redirect_to new_user_session_path if !params.has_key?(:code)
|
||||
if params[:code].nil?
|
||||
return redirect_to new_user_session_path
|
||||
end
|
||||
|
||||
user_infos = FranceConnectService.retrieve_user_informations_particulier(params[:code])
|
||||
|
||||
if user_infos.present?
|
||||
france_connect_information = FranceConnectInformation.find_by_france_connect_particulier user_infos
|
||||
france_connect_information = FranceConnectInformation.find_by_france_connect_particulier(user_infos)
|
||||
|
||||
if france_connect_information.nil?
|
||||
france_connect_information = FranceConnectInformation.create(
|
||||
{gender: user_infos[:gender],
|
||||
given_name: user_infos[:given_name],
|
||||
|
@ -19,14 +22,17 @@ class FranceConnect::ParticulierController < ApplicationController
|
|||
birthdate: user_infos[:birthdate],
|
||||
birthplace: user_infos[:birthplace],
|
||||
france_connect_particulier_id: user_infos[:france_connect_particulier_id]}
|
||||
) if france_connect_information.nil?
|
||||
)
|
||||
end
|
||||
|
||||
user = france_connect_information.user
|
||||
salt = FranceConnectSaltService.new(france_connect_information).salt
|
||||
|
||||
return redirect_to france_connect_particulier_new_path(fci_id: france_connect_information.id, salt: salt) if user.nil?
|
||||
if user.nil?
|
||||
return redirect_to france_connect_particulier_new_path(fci_id: france_connect_information.id, salt: salt)
|
||||
end
|
||||
|
||||
connect_france_connect_particulier user
|
||||
connect_france_connect_particulier(user)
|
||||
end
|
||||
rescue Rack::OAuth2::Client::Error => e
|
||||
Rails.logger.error e.message
|
||||
|
|
Loading…
Reference in a new issue