New passport server
This commit is contained in:
parent
6522e41d49
commit
9987c820f9
4 changed files with 28 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
module OmniAuth
|
||||
module MapsMe
|
||||
VERSION = "1.0.3"
|
||||
VERSION = "1.0.4"
|
||||
end
|
||||
|
||||
module MapsMeToken
|
||||
|
|
|
@ -2,12 +2,30 @@ module OmniAuth
|
|||
module Strategies
|
||||
module MapsMeBase
|
||||
MAPSME_BASE = 'https://passport.maps.me'
|
||||
MAPSME_DEFAULT_SCOPE = 'read'
|
||||
MAPSME_USER_DETAILS = '/user_details/'
|
||||
|
||||
MAPSME_CLIENT_OPTIONS = {
|
||||
:site => MAPSME_BASE,
|
||||
:authorize_url => "#{MAPSME_BASE}/oauth/authorize",
|
||||
:token_url => "#{MAPSME_BASE}/oauth/token"
|
||||
:token_url => "#{MAPSME_BASE}/oauth/token/"
|
||||
}
|
||||
|
||||
def extract_name(raw_info)
|
||||
first_name = raw_info['first_name']
|
||||
last_name = raw_info['last_name']
|
||||
username = raw_info['username']
|
||||
|
||||
if first_name
|
||||
if last_name
|
||||
"#{first_name} #{last_name}"
|
||||
else
|
||||
first_name
|
||||
end
|
||||
else
|
||||
username
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,12 +24,12 @@ module OmniAuth
|
|||
|
||||
attr_accessor :access_token
|
||||
|
||||
uid { raw_info['uid'].to_s }
|
||||
uid { raw_info['username'] }
|
||||
|
||||
info do
|
||||
prune!({
|
||||
'email' => raw_info['email'],
|
||||
'name' => raw_info['name']
|
||||
'name' => extract_name(raw_info)
|
||||
})
|
||||
end
|
||||
|
||||
|
@ -47,12 +47,12 @@ module OmniAuth
|
|||
|
||||
def authorize_params
|
||||
super.tap do |params|
|
||||
params[:scope] = 'user mail'
|
||||
params[:scope] = MAPSME_DEFAULT_SCOPE
|
||||
end
|
||||
end
|
||||
|
||||
def raw_info
|
||||
@raw_info ||= access_token.get('/user').parsed || {}
|
||||
@raw_info ||= access_token.get(MAPSME_USER_DETAILS).parsed || {}
|
||||
end
|
||||
|
||||
def info_options
|
||||
|
|
|
@ -10,12 +10,12 @@ module OmniAuth
|
|||
|
||||
option :client_options, MAPSME_CLIENT_OPTIONS
|
||||
|
||||
uid { raw_info['uid'].to_s }
|
||||
uid { raw_info['username'] }
|
||||
|
||||
info do
|
||||
{
|
||||
'email' => raw_info['email'],
|
||||
'name' => raw_info['name']
|
||||
'name' => extract_name(raw_info)
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -25,12 +25,12 @@ module OmniAuth
|
|||
|
||||
def authorize_params
|
||||
super.tap do |params|
|
||||
params[:scope] = 'user mail'
|
||||
params[:scope] = MAPSME_DEFAULT_SCOPE
|
||||
end
|
||||
end
|
||||
|
||||
def raw_info
|
||||
@raw_info ||= access_token.get('/user').parsed || {}
|
||||
@raw_info ||= access_token.get(MAPSME_USER_DETAILS).parsed || {}
|
||||
end
|
||||
|
||||
# Fix omniauth-oauth2 issue https://github.com/intridea/omniauth-oauth2/issues/76
|
||||
|
|
Loading…
Add table
Reference in a new issue