Sha256: 559d5890af349e0b56c703a49ce0b5a59a987c0bac977ea0c1ef5977e2d6661a
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require 'pp' require 'json' module Example class App < Sinatra::Base enable :sessions set :github_options, { :scopes => "user", :secret => ENV['GITHUB_CLIENT_SECRET'], :client_id => ENV['GITHUB_CLIENT_ID'], } register Sinatra::Auth::Github helpers do def repos github_request("user/repos") end end get '/' do authenticate! "Hello there, #{github_user.login}!" end get '/orgs/:id' do github_organization_authenticate!(params['id']) "Hello There, #{github_user.name}! You have access to the #{params['id']} organization." end get '/publicized_orgs/:id' do github_publicized_organization_authenticate!(params['id']) "Hello There, #{github_user.name}! You are publicly a member of the #{params['id']} organization." end get '/teams/:id' do github_team_authenticate!(params['id']) "Hello There, #{github_user.name}! You have access to the #{params['id']} team." end get '/logout' do logout! redirect 'https://github.com' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sinatra_auth_github-2.0.0 | spec/app.rb |
sinatra_auth_github-2.0.0.pre1 | spec/app.rb |
sinatra_auth_github-1.2.0 | spec/app.rb |