lib/stoor/github_auth.rb in stoor-0.1.4 vs lib/stoor/github_auth.rb in stoor-0.1.5
- old
+ new
@@ -1,12 +1,12 @@
module Stoor
class GithubAuth < Sinatra::Base
set :github_options, {
- :scopes => "user,user:email",
- :client_id => ENV['GITHUB_CLIENT_ID'],
- :secret => ENV['GITHUB_CLIENT_SECRET']
+ :scopes => "user:email",
+ :client_id => ENV['STOOR_GITHUB_CLIENT_ID'],
+ :secret => ENV['STOOR_GITHUB_CLIENT_SECRET']
}
register Sinatra::Auth::Github
register Mustache::Sinatra
@@ -14,26 +14,26 @@
logout!
mustache :logout
end
get '/*' do
- ENV['GITHUB_AUTHORIZED'] = nil
+ session['stoor.github.authorized'] = nil
- pass unless ENV['GITHUB_CLIENT_ID'] && ENV['GITHUB_CLIENT_SECRET']
+ pass unless ENV['STOOR_GITHUB_CLIENT_ID'] && ENV['STOOR_GITHUB_CLIENT_SECRET']
pass if request.path_info =~ /\./
authenticate!
- if ENV['GITHUB_TEAM_ID']
- github_team_authenticate!(ENV['GITHUB_TEAM_ID'])
+ if ENV['STOOR_GITHUB_TEAM_ID']
+ github_team_authenticate!(ENV['STOOR_GITHUB_TEAM_ID'])
end
- ENV['GITHUB_AUTHORIZED'] = "yes"
+ session['stoor.github.authorized'] = 'yes'
email = nil
emails = github_user.api.emails
- if ENV['GITHUB_EMAIL_DOMAIN']
- email = emails.find { |e| e =~ /#{ENV['GITHUB_EMAIL_DOMAIN']}/ }
+ if ENV['STOOR_GITHUB_EMAIL_DOMAIN']
+ email = emails.find { |e| e =~ /#{ENV['STOOR_GITHUB_EMAIL_DOMAIN']}/ }
end
email ||= emails.first
session['gollum.author'] = { :name => github_user.name, :email => email }
pass
end