lib/sinatra/auth/github.rb in sinatra_auth_github-0.0.6 vs lib/sinatra/auth/github.rb in sinatra_auth_github-0.0.7
- old
+ new
@@ -1,6 +1,7 @@
require 'sinatra/base'
+require 'sinatra/url_for'
require 'warden-github'
module Sinatra
module Auth
module Github
@@ -34,10 +35,14 @@
def github_request(path)
response = RestClient.get("https://github.com/api/v2/json/#{path}", {:accept => :json, :params => {:token => github_user.token}})
JSON.parse(response.body)
end
+
+ def _relative_url_for(path)
+ request.script_name + path
+ end
end
def self.registered(app)
app.use Warden::Manager do |manager|
manager.default_strategies :github
@@ -48,13 +53,14 @@
manager[:github_client_id] = app.github_options[:client_id]
manager[:github_callback_url] = app.github_options[:callback_url] || '/auth/github/callback'
end
app.helpers Helpers
+ app.helpers Sinatra::UrlForHelper
app.get '/auth/github/callback' do
authenticate!
- redirect url_for '/'
+ redirect _relative_url_for('/')
end
end
end
end
end