Class: OmniAuth::Strategies::Ourkudos

Inherits:
OAuth2
  • Object
show all
Includes:
OmniAuth::Strategy
Defined in:
lib/ourkudos/strategies/strategy.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, client_id = nil, client_secret = nil, options = {}, &block) ⇒ Ourkudos

Returns a new instance of Ourkudos.



9
10
11
# File 'lib/ourkudos/strategies/strategy.rb', line 9

def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)      
  super app, :ourkudos, client_id, client_secret, {:site => 'http://localhost:3000'}, options, &block
end

Instance Method Details

#auth_hashObject



31
32
33
34
35
36
37
# File 'lib/ourkudos/strategies/strategy.rb', line 31

def auth_hash
  OmniAuth::Utils.deep_merge(super, {
    'uid'       => user_data["user"]["id"],
    'user_info' => ,
    'extra'     => {'user_hash' => user_data}
  })
end

#request_phaseObject



13
14
15
16
# File 'lib/ourkudos/strategies/strategy.rb', line 13

def request_phase
  options[:response_type] ||= 'code'
  super
end

#user_dataObject



18
19
20
# File 'lib/ourkudos/strategies/strategy.rb', line 18

def user_data
 @data ||= MultiJson.decode(@access_token.get(client.site + '/oauth/user', {'oauth_token' => @access_token.token}))
end

#user_infoObject



22
23
24
25
26
27
28
29
# File 'lib/ourkudos/strategies/strategy.rb', line 22

def 
  {
    'email'      => (user_data["email"] if user_data["email"]),
    'first_name' => user_data["first_name"],
    'last_name'  => user_data["last_name"],
    'name'       => "#{user_data['first_name']} #{user_data['last_name']}"
  }
end