Class: ExvoAuth::Strategies::Base
- Inherits:
-
OmniAuth::Strategies::OAuth2
- Object
- OmniAuth::Strategies::OAuth2
- ExvoAuth::Strategies::Base
show all
- Defined in:
- lib/exvo_auth/strategies/base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(app, name, options = {}) ⇒ Base
Returns a new instance of Base.
2
3
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/exvo_auth/strategies/base.rb', line 2
def initialize(app, name, options = {})
options[:site] ||= ExvoAuth::Config.uri
options[:client_id] ||= ExvoAuth::Config.client_id
options[:client_secret] ||= ExvoAuth::Config.client_secret
options[:token_url] ||= "/oauth/access_token"
if options[:site].nil? || options[:client_id].nil? || options[:client_secret].nil?
raise(ArgumentError, "Please configure uri, client_id and client_secret")
end
super(app, name, options.delete(:client_id), options.delete(:client_secret), options)
end
|
Instance Method Details
#auth_hash ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/exvo_auth/strategies/base.rb', line 27
def auth_hash
OmniAuth::Utils.deep_merge(super, {
'provider' => 'exvo',
'uid' => user_data['id'],
'user_info' => user_info,
'extra' => { 'user_hash' => user_data }
})
end
|
#user_data ⇒ Object
15
16
17
18
|
# File 'lib/exvo_auth/strategies/base.rb', line 15
def user_data
@access_token.options.merge!({:param_name => :access_token, :mode => :query})
@data ||= MultiJson.decode(@access_token.get('/user.json').body)
end
|
#user_info ⇒ Object
20
21
22
23
24
25
|
# File 'lib/exvo_auth/strategies/base.rb', line 20
def user_info
{
'nickname' => user_data['nickname'],
'email' => user_data['email']
}.reject{ |k, v| v.nil? }
end
|