Class: OmniAuth::Strategies::JobRocket
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::JobRocket
- Defined in:
- lib/omniauth/strategies/jobrocket.rb
Instance Method Summary collapse
- #authorize_params ⇒ Object
- #email ⇒ Object
- #email_access_allowed? ⇒ Boolean
-
#emails ⇒ Object
The new /user/emails API - developer.github.com/v3/users/emails/#future-response.
- #primary_email ⇒ Object
- #raw_info ⇒ Object
- #request_phase ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/omniauth/strategies/jobrocket.rb', line 16 def 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 |
#email ⇒ Object
46 47 48 |
# File 'lib/omniauth/strategies/jobrocket.rb', line 46 def email (email_access_allowed?) ? primary_email : raw_info['email'] end |
#email_access_allowed? ⇒ Boolean
62 63 64 |
# File 'lib/omniauth/strategies/jobrocket.rb', line 62 def email_access_allowed? ['scope'] =~ /user/ end |
#emails ⇒ Object
The new /user/emails API - developer.github.com/v3/users/emails/#future-response
56 57 58 59 60 |
# File 'lib/omniauth/strategies/jobrocket.rb', line 56 def emails return [] unless email_access_allowed? access_token.[:mode] = :query @emails ||= access_token.get('user/emails', :headers => { 'Accept' => 'application/vnd.github.v3' }).parsed end |
#primary_email ⇒ Object
50 51 52 53 |
# File 'lib/omniauth/strategies/jobrocket.rb', line 50 def primary_email primary = emails.find{|i| i['primary'] } primary && primary['email'] || emails.first && emails.first['email'] end |
#raw_info ⇒ Object
41 42 43 44 |
# File 'lib/omniauth/strategies/jobrocket.rb', line 41 def raw_info access_token.[:mode] = :query @raw_info ||= access_token.get('user').parsed end |
#request_phase ⇒ Object
12 13 14 |
# File 'lib/omniauth/strategies/jobrocket.rb', line 12 def request_phase super end |