Skip to content
Snippets Groups Projects
Commit a14e95c0 authored by Tyler Lemburg's avatar Tyler Lemburg
Browse files

Kiosk logout

parent ada6666c
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,12 @@ require 'rack/session/abstract/id'
require 'rack/cas'
require 'rack-cas'
require 'rack-cas/session_store/active_record'
require 'models/session'
require 'models/user'
require 'models/service_space'
include ERB::Util
module Rack
module Session
class RackCASActiveRecordStore < Rack::Session::Abstract::ID
......@@ -34,6 +37,8 @@ def flash(type, header, message)
end
before do
session['init'] = true
# site defaults
@title = 'UNL Resource Scheduler'
@breadcrumbs = [
......@@ -70,7 +75,7 @@ helpers do
raise Sinatra::NotFound if space.nil?
@space = space
if defined?(@user) && !@user.in_space?(@space)
if @user && !@user.in_space?(@space)
flash :error, 'Unauthorized', 'Sorry, you don\'t have access to this service space.'
redirect '/'
end
......@@ -137,9 +142,15 @@ get '/' do
}
end
get '/logout/' do
session.delete('cas')
redirect back
get '/kiosk-logout/' do
ticket = session['cas'] ? session['cas']['ticket'] : nil
Session.delete_all(cas_ticket: ticket)
session.send (session.respond_to?(:destroy) ? :destroy : :clear)
erb :kiosk_logout, :layout => :fixed, :locals => {
url_redirect: params[:url_redirect]
}
end
Dir.glob("#{ROOT}/routes/*.rb") { |file| require file }
\ No newline at end of file
require 'active_record'
class Session < ActiveRecord::Base
end
\ No newline at end of file
......@@ -60,6 +60,8 @@ get '/:service_space_url_name/resources/:resource_id/calendar/?' do
end
end
puts session.inspect
erb :resource_calendar, :layout => :fixed, :locals => {
:date => date,
:sunday => sunday,
......
......@@ -16,7 +16,6 @@
<!-- InstanceBeginEditable name="head" -->
<!-- Place optional header elements here -->
<link rel="stylesheet" href="/css/resource_scheduler.css">
<link rel="stylesheet" href="/css/jquery-ui.min-custom.css">
<script type="text/javascript">WDN.initializePlugin("notice");</script>
<!-- InstanceEndEditable -->
<!-- InstanceParam name="class" type="text" value="" -->
......
<div id="pagetitle">
<h3>Logging you out...</h3>
</div>
<h5>Don't worry, we'll redirect out of here</h5>
<a href="<%= url_redirect %>">If you don't want to wait</a><br><br>
<iframe style="width: 100%; min-height: 400px" src="https://login.unl.edu/cas/logout">
</iframe>
<script type="text/javascript">
setTimeout(function () {
window.location = <%= url_redirect.inspect %>;
}, 5000);
</script>
\ No newline at end of file
......@@ -10,7 +10,7 @@ end %>
<div style="position: absolute; top: 1em; right: 1em; text-align: right;">
<% if @user %>
<a style="font-size: 1.25em;" class="wdn-button wdn-button-triad" href="/logout/">Log Out</a>
<a style="font-size: 1.5em;" class="wdn-button wdn-button-triad" href="/kiosk-logout/?url_redirect=<%= url_encode("/#{@space.url_name}/resources/#{resource.id}/calendar/") %>">Log Out</a>
<% end %>
<a style="font-size: 1.5em;" class="wdn-button wdn-button-brand" href="/<%= @space.url_name %>/resources/<%= resource.id %>/reserve/">Reserve Me!</a>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment