31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/sinatra/hancock/sessions.rb', line 31
def self.registered(app)
app.send(:include, Sinatra::Hancock::Sessions::Helpers)
app.template(:unauthenticated) { sessions_template('unauthenticated') }
app.get '/sso/login' do
ensure_authenticated
redirect '/'
end
app.post '/sso/login' do
@user = ::Hancock::User.authenticate(params['email'], params['password'])
if @user
session['hancock_server_user_id'] = @user.id
end
ensure_authenticated
redirect session['hancock_server_return_to'] || '/'
end
app.get '/sso/logout' do
session.clear
redirect '/'
end
end
|