FC ParticulierClient: simplier initialize
This commit is contained in:
parent
8c487c65a9
commit
4c2da46dd8
3 changed files with 8 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
class FranceConnectParticulierClient < OpenIDConnect::Client
|
||||
def initialize params={}
|
||||
def initialize(code = nil)
|
||||
super(
|
||||
identifier: FRANCE_CONNECT.particulier_identifier,
|
||||
secret: FRANCE_CONNECT.particulier_secret,
|
||||
|
@ -11,6 +11,9 @@ class FranceConnectParticulierClient < OpenIDConnect::Client
|
|||
userinfo_endpoint: FRANCE_CONNECT.particulier_userinfo_endpoint,
|
||||
logout_endpoint: FRANCE_CONNECT.particulier_logout_endpoint
|
||||
)
|
||||
self.authorization_code = params[:code] if params.has_key? :code
|
||||
|
||||
if code.present?
|
||||
self.authorization_code = code
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class FranceConnectService
|
||||
def self.retrieve_user_informations_particulier code
|
||||
client = FranceConnectParticulierClient.new code: code
|
||||
client = FranceConnectParticulierClient.new(code)
|
||||
|
||||
access_token = client.access_token!(client_auth_method: :secret)
|
||||
user_info = access_token.userinfo!
|
||||
|
|
|
@ -7,10 +7,10 @@ describe FranceConnectParticulierClient do
|
|||
end
|
||||
context 'when given code in params' do
|
||||
let(:code) { 'plop' }
|
||||
subject { described_class.new(code: code) }
|
||||
subject { described_class.new(code) }
|
||||
it 'set authorisation code' do
|
||||
expect_any_instance_of(described_class).to receive(:authorization_code=).with(code)
|
||||
described_class.new(code: code)
|
||||
described_class.new(code)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue