Class: Authkeeper::Providers::Yandex

Inherits:
Object
  • Object
show all
Defined in:
app/services/authkeeper/providers/yandex.rb

Instance Method Summary collapse

Instance Method Details

#call(params: {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/authkeeper/providers/yandex.rb', line 11

def call(params: {})
  auth_info = fetch_auth_info(params[:code])
  return { errors: ['Invalid code'] } if auth_info.nil?
  return { errors: ['Invalid code'] } unless auth_info['access_token']

   = (auth_info['access_token'])
  {
    result: {
      auth_info: auth_info.symbolize_keys,
      user_info: {
        uid: ['id'].to_s,
        provider: 'yandex',
        username: ['login'],
        email: ['default_email'],
        phone_number: .dig('default_phone', 'number')
      }
    }
  }
end