Class: Morpho::Operations::User::ExternalSignIn
Instance Method Summary
collapse
#check!, #data!, #validate!
Methods inherited from Base::Find
#model_class!, #params!, #presenter_class!
Instance Method Details
#build_model!(options, data:) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/concepts/morpho/operations/user/external_sign_in.rb', line 7
def build_model!(options, data:, **)
provider = data.fetch('provider').downcase
options['model'] = Morpho::User.load_from_provider(
provider, data.fetch('uid')
)
if options['model'].nil?
options['model'] = Morpho::User.find_by(email: data.fetch('email'))
unless options['model'].nil?
options['model'].add_provider_to_user(provider, data.fetch('uid'))
end
end
if options['model'].nil?
options['model'] = Morpho::User.create_from_provider(provider, data.fetch('uid'), {
email: data.fetch('email')
})
end
end
|
#present!(options, model:) ⇒ Object
29
30
31
32
33
34
|
# File 'app/concepts/morpho/operations/user/external_sign_in.rb', line 29
def present!(options, model:, **)
model.generate_refresh_token!
model.register_last_login_activity!(options['ip_address'])
token = Morpho::JWT::Payload.new(model)
options['response'] = options['presenter.class'].represent(token)
end
|