warden-github 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/warden-github.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'warden'
2
2
  require 'oauth2'
3
- require 'json'
3
+ require 'yajl'
4
4
 
5
5
  module Warden
6
6
  module Github
@@ -10,12 +10,7 @@ Warden::Strategies.add(:github) do
10
10
  begin
11
11
  api = api_for(params['code'])
12
12
 
13
- resp = api.get '/api/v2/json/user/show' do |request|
14
- request.params['access_token'] = api.token
15
- end.body
16
-
17
- user = JSON.load(resp)
18
- success!(Warden::Github::Oauth::User.new(user['user'], api.token))
13
+ success!(Warden::Github::Oauth::User.new(Yajl.load(user_info_for(api.token)), api.token))
19
14
  rescue OAuth2::Error
20
15
  %(<p>Outdated ?code=#{params['code']}:</p><p>#{$!}</p><p><a href="/auth/github">Retry</a></p>)
21
16
  end
@@ -47,6 +42,10 @@ Warden::Strategies.add(:github) do
47
42
  callback_url)
48
43
  end
49
44
 
45
+ def user_info_for(token)
46
+ @user_info ||= RestClient.get("https://api.github.com/user", :params => {:access_token => token})
47
+ end
48
+
50
49
  def callback_url
51
50
  absolute_url(request, env['warden'].config[:github_callback_url], env['HTTP_X_FORWARDED_PROTO'])
52
51
  end
@@ -1,5 +1,5 @@
1
1
  module Warden
2
2
  module Github
3
- VERSION = "0.6.1"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warden-github
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
9
- - 1
10
- version: 0.6.1
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Corey Donohoe
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-04 00:00:00 -07:00
18
+ date: 2012-06-12 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency