mirror of
https://github.com/elyby/omniauth-ely.git
synced 2025-05-31 14:11:40 +05:30
Initial commit
This commit is contained in:
49
lib/omniauth/strategies/ely.rb
Normal file
49
lib/omniauth/strategies/ely.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require 'omniauth-oauth2'
|
||||
|
||||
module OmniAuth
|
||||
module Strategies
|
||||
class Ely < OmniAuth::Strategies::OAuth2
|
||||
option :client_options, {
|
||||
:site => 'https://account.ely.by',
|
||||
:authorize_url => 'https://account.ely.by/oauth2/v1/',
|
||||
:token_url => 'https://account.ely.by/api/oauth2/v1/token',
|
||||
}
|
||||
|
||||
uid { raw_info['id'].to_s }
|
||||
|
||||
info do
|
||||
{
|
||||
:name => raw_info['username'],
|
||||
:email => raw_info['email'],
|
||||
:urls => {
|
||||
:Ely => profile_url,
|
||||
:Skin => skin_url,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
extra do
|
||||
{
|
||||
:raw_info => raw_info,
|
||||
:uuid => raw_info['uuid'],
|
||||
:registered_at => raw_info['registeredAt'],
|
||||
:preferred_language => raw_info['preferredLanguage']
|
||||
}
|
||||
end
|
||||
|
||||
def raw_info
|
||||
@raw_info ||= access_token.get('https://account.ely.by/api/account/v1/info').parsed
|
||||
end
|
||||
|
||||
def skin_url
|
||||
'http://skinsystem.ely.by/skins/' + raw_info['username'] + '.png'
|
||||
end
|
||||
|
||||
def profile_url
|
||||
'http://ely.by/u' + raw_info['id'].to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
OmniAuth.config.add_camelization 'ely', 'Ely'
|
||||
Reference in New Issue
Block a user