Created
June 1, 2010 23:59
-
-
Save atmos/421704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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