Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use bubbled up return_to from warden

  • Loading branch information...
commit 5aefdfd181355e7cc390fe7059ee24697111caf6 1 parent 469b0b8
@atmos atmos authored
View
15 lib/sinatra/auth/github.rb
@@ -5,7 +5,7 @@
module Sinatra
module Auth
module Github
- VERSION = "0.1.1"
+ VERSION = "0.1.2"
# Simple way to serve an image early in the stack and not get blocked by
# application level before filters
@@ -87,7 +87,7 @@ def github_request(path)
def github_organization_access?(name)
orgs = github_request("orgs/#{name}/members")
orgs.map { |org| org["login"] }.include?(github_user.login)
- rescue RestClient::Unauthorized, RestClient::ResourceNotFound => e
+ rescue RestClient::Forbidden, RestClient::Unauthorized, RestClient::ResourceNotFound => e
false
end
@@ -99,7 +99,7 @@ def github_organization_access?(name)
def github_team_access?(team_id)
members = github_request("teams/#{team_id}/members")
members.map { |user| user["login"] }.include?(github_user.login)
- rescue RestClient::Unauthorized, RestClient::ResourceNotFound => e
+ rescue RestClient::Forbidden, RestClient::Unauthorized, RestClient::ResourceNotFound => e
false
end
@@ -135,9 +135,9 @@ def self.registered(app)
manager.failure_app = app.github_options[:failure_app] || BadAuthentication
- manager[:github_secret] = app.github_options[:secret]
- manager[:github_scopes] = app.github_options[:scopes] || 'email,offline_access'
- manager[:github_client_id] = app.github_options[:client_id]
+ manager[:github_secret] = app.github_options[:secret] || ENV['GITHUB_CLIENT_SECRET']
+ manager[:github_scopes] = app.github_options[:scopes] || 'email,offline_access'
+ manager[:github_client_id] = app.github_options[:client_id] || ENV['GITHUB_CLIENT_ID']
manager[:github_callback_url] = app.github_options[:callback_url] || '/auth/github/callback'
end
@@ -145,7 +145,8 @@ def self.registered(app)
app.get '/auth/github/callback' do
authenticate!
- redirect _relative_url_for('/')
+ return_to = session.delete('return_to') || _relative_url_for('/')
+ redirect return_to
end
end
end
View
4 sinatra_auth_github.gemspec
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
s.name = "sinatra_auth_github"
- s.version = "0.1.1"
+ s.version = "0.1.2"
s.platform = Gem::Platform::RUBY
s.authors = ["Corey Donohoe"]
s.email = ["atmos@atmos.org"]
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
s.add_dependency "sinatra", "~>1.0"
s.add_dependency "rest-client", "~>1.6.1"
- s.add_dependency "warden-github", "~>0.1.0"
+ s.add_dependency "warden-github", "~>0.1.1"
s.add_development_dependency "rake"
s.add_development_dependency "rspec", "~>1.3.0"
View
2  spec/app.rb
@@ -35,7 +35,7 @@ def repos
get '/logout' do
logout!
- redirect '/'
+ redirect 'https://github.com'
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.