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']
user_info = fetch_user_info(auth_info['access_token'])
{
result: {
auth_info: auth_info.symbolize_keys,
user_info: {
uid: user_info['id'].to_s,
provider: 'yandex',
username: user_info['login'],
email: user_info['default_email'],
phone_number: user_info.dig('default_phone', 'number')
}
}
}
end
|