Class: OmniAuth::Strategies::Cisimple
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Cisimple
show all
- Defined in:
- lib/omniauth/strategies/cisimple.rb
Defined Under Namespace
Classes: NoAuthorizationCodeError
Instance Method Summary
collapse
Instance Method Details
#access_token_options ⇒ Object
47
48
49
|
# File 'lib/omniauth/strategies/cisimple.rb', line 47
def access_token_options
options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
end
|
#authorize_params ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/omniauth/strategies/cisimple.rb', line 22
def authorize_params
super.tap do |params|
%w[scope client_options].each do |v|
if request.params[v]
params[v.to_sym] = request.params[v]
end
end
end
end
|
#build_access_token ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/omniauth/strategies/cisimple.rb', line 51
def build_access_token
if access_token = request.params["access_token"]
::OAuth2::AccessToken.from_hash(
client,
{"access_token" => access_token}.update(access_token_options)
)
else
with_authorization_code! { super }.tap do |token|
token.options.merge!(access_token_options)
end
end
end
|
#email ⇒ Object
72
73
74
|
# File 'lib/omniauth/strategies/cisimple.rb', line 72
def email
raw_info['email']
end
|
#email_access_allowed? ⇒ Boolean
84
85
86
|
# File 'lib/omniauth/strategies/cisimple.rb', line 84
def email_access_allowed?
options['scope'] =~ /user/
end
|
#image ⇒ Object
76
77
78
|
# File 'lib/omniauth/strategies/cisimple.rb', line 76
def image
raw_info['avatar_url']
end
|
#nickname ⇒ Object
80
81
82
|
# File 'lib/omniauth/strategies/cisimple.rb', line 80
def nickname
raw_info['nickname']
end
|
#raw_info ⇒ Object
42
43
44
45
|
# File 'lib/omniauth/strategies/cisimple.rb', line 42
def raw_info
access_token.options[:mode] = :query
@raw_info ||= access_token.get('user').parsed
end
|
#request_phase ⇒ Object
14
15
16
|
# File 'lib/omniauth/strategies/cisimple.rb', line 14
def request_phase
super
end
|
#with_authorization_code! ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/omniauth/strategies/cisimple.rb', line 64
def with_authorization_code!
if request.params.key?('code')
yield
else
raise NoAuthorizationCodeError, 'must pass code parameter'
end
end
|