Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@atmos
Created June 1, 2010 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atmos/421704 to your computer and use it in GitHub Desktop.
Save atmos/421704 to your computer and use it in GitHub Desktop.
require 'pp'
require 'sinatra/auth/github'
module Signup
def self.app
@app ||= Rack::Builder.new do
use Rack::Static, :urls => ["/stylesheets", "/images", "/javascripts"], :root => "public"
run Signup::App
end
end
def self.oauth_config
case ENV['RACK_ENV']
when 'production'
{:client_id => '', :secret => '' }
when 'staging'
{:client_id => '', :secret => '' }
else
{:client_id => '', :secret => '' }
end
end
class App < Sinatra::Base
enable :sessions
enable :raise_errors
disable :show_exceptions
set :root, File.expand_path(File.dirname(__FILE__))
set :github_options, Signup.oauth_config
register Sinatra::Auth::Github
get '/' do
if authenticated?
"<p>Your OAuth access token: #{github_user.token}</p><p>Your extended profile data:\n#{github_user.inspect}</p>"
else
"<h3><a href="/authenticate">Get Started Now...</a></h3>"
end
end
get '/authenticate' do
authenticate!
end
get '/logout' do
logout!
redirect '/'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment