-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.rb
73 lines (58 loc) · 1.56 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require_relative 'init'
require_relative 'lib/partials'
class App < Sinatra::Application
enable :sessions
disable :protection
configure :development do
set :boss_data_server, 'http://127.0.0.1:9292/'
set :internal_boss_data_server, 'http://127.0.0.1:9292/'
# set :boss_data_server, 'http://frank-prodsup.lifetimefitness.com/api/'
# set :internal_boss_data_server, 'http://frank-prodsup.lifetimefitness.com/api/'
register Sinatra::Reloader
set :reload_templates, true
end
configure :prodsup do
set :boss_data_server, 'http://frank-prodsup.lifetimefitness.com/api/'
set :internal_boss_data_server, 'http://127.0.0.1/api/'
end
helpers do
include Sinatra::Partials
def ssoid
session['ssoid']
end
def require_authenticated!
redirect to('/login') if session['ssoid'].nil?
end
end
get '/' do
require_authenticated!
render :erb, :index
end
get '/member' do
require_authenticated!
render :erb, :member
end
get '/member/photo' do
require_authenticated!
response.headers['content-type'] = "image/jpeg"
response.headers['content-disposition'] = 'inline'
stream do |out|
File.open("#{settings.public_folder}/images/member_photo.jpeg", 'r') do |f|
out << f.read
end
end
end
get '/login' do
redirect to('/') if !session['ssoid'].nil? && session['ssoid'] != ''
render :erb, :login
end
get '/logout' do
session.clear
redirect to('/login')
end
get '/auth_callback' do
redirect to('/login') if params['ssoid'].nil? || params['ssoid'] == ''
session['ssoid'] = params['ssoid']
redirect to('/')
end
end