-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.rb
46 lines (37 loc) · 1.07 KB
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'pp'
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