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
|
# File 'lib/exvo_auth/strategies/base.rb', line 2
def initialize(app, name, options = {})
options[:site] ||= ExvoAuth::Config.host
options[:client_id] ||= ExvoAuth::Config.client_id
options[:client_secret] ||= ExvoAuth::Config.client_secret
if options[:site].nil? || options[:client_id].nil? || options[:client_secret].nil?
raise(ArgumentError, "Please configure host, 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
25
26
27
28
29
30
31
32
|
# File 'lib/exvo_auth/strategies/base.rb', line 25
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
14
15
16
|
# File 'lib/exvo_auth/strategies/base.rb', line 14
def user_data
@data ||= MultiJson.decode(@access_token.get('/user.json'))
end
|
#user_info ⇒ Object
18
19
20
21
22
23
|
# File 'lib/exvo_auth/strategies/base.rb', line 18
def user_info
{
'nickname' => user_data['nickname'],
'email' => user_data['email']
}.reject{ |k, v| v.nil? }
end
|