warden-github 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,12 +10,12 @@ 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|
13
+ resp = api.get '/api/v3/user' do |request|
14
14
  request.params['access_token'] = api.token
15
15
  end.body
16
16
 
17
17
  user = JSON.load(resp)
18
- success!(Warden::Github::Oauth::User.new(user['user'], api.token))
18
+ success!(Warden::Github::Oauth::User.new(user, api.token))
19
19
  rescue OAuth2::Error
20
20
  %(<p>Outdated ?code=#{params['code']}:</p><p>#{$!}</p><p><a href="/auth/github">Retry</a></p>)
21
21
  end
@@ -48,16 +48,16 @@ Warden::Strategies.add(:github) do
48
48
  end
49
49
 
50
50
  def callback_url
51
- absolute_url(request, env['warden'].config[:github_callback_url])
51
+ absolute_url(request, env['warden'].config[:github_callback_url], env['HTTP_X_FORWARDED_PROTO'])
52
52
  end
53
53
 
54
- def absolute_url(request, suffix = nil)
54
+ def absolute_url(request, suffix = nil, proto = "http")
55
55
  port_part = case request.scheme
56
56
  when "http"
57
57
  request.port == 80 ? "" : ":#{request.port}"
58
58
  when "https"
59
59
  request.port == 443 ? "" : ":#{request.port}"
60
60
  end
61
- "#{request.scheme}://#{request.host}#{port_part}#{suffix}"
61
+ "#{proto}://#{request.host}#{port_part}#{suffix}"
62
62
  end
63
63
  end
@@ -1,5 +1,5 @@
1
1
  module Warden
2
2
  module Github
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
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-03-01 00:00:00 -08:00
18
+ date: 2012-05-24 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency