FC ParticulierController: use find or tap

This commit is contained in:
simon lehericey 2018-01-15 21:06:47 +01:00 committed by Simon Lehericey
parent 7cbd6ed067
commit c6c4dd7c7e

View file

@ -11,12 +11,8 @@ class FranceConnect::ParticulierController < ApplicationController
fetched_fc_information = FranceConnectService.retrieve_user_informations_particulier(params[:code]) fetched_fc_information = FranceConnectService.retrieve_user_informations_particulier(params[:code])
france_connect_information = FranceConnectInformation france_connect_information = FranceConnectInformation
.find_by(france_connect_particulier_id: fetched_fc_information[:france_connect_particulier_id]) .find_by(france_connect_particulier_id: fetched_fc_information[:france_connect_particulier_id]) ||
fetched_fc_information.tap { |object| object.save }
if france_connect_information.nil?
fetched_fc_information.save
france_connect_information = fetched_fc_information
end
user = france_connect_information.user user = france_connect_information.user
salt = FranceConnectSaltService.new(france_connect_information).salt salt = FranceConnectSaltService.new(france_connect_information).salt