Commit 430f98ad authored by igoshin's avatar igoshin Committed by Matija Obreza
Browse files

Session expiration warning

parent 323139a5
......@@ -487,3 +487,7 @@ navigate.back=Back
content.page.list.title=Article list
article.lang=Language
article.classPk=Object
session.expiry-warning-title=Session expiration warning
session.expiry-warning=Your current session is about to expire. Do you wish to extend this session?
session.expiry-extend=Extend session
......@@ -36,3 +36,4 @@ log4j.rootLogger=info, stdout
#log4j.category.com.hazelcast=warn
#log4j.category.com.hazelcast.web=debug
#log4j.category.com.hazelcast.aws=trace
#log4j.category.org.eclipse.jetty.servlets=trace
\ No newline at end of file
......@@ -55,6 +55,7 @@
<!--Override default login and logout pages -->
<sec:form-login login-page="/login" authentication-failure-url="/login?error=1" login-processing-url="/login-attempt" default-target-url="/" always-use-default-target="false" />
<sec:session-management session-fixation-protection="migrateSession" />
<sec:logout logout-url="/logout" logout-success-url="/" />
......
......@@ -2,7 +2,7 @@
<!-- footer start -->
<div id="footer">
<div class="container">
<div id="nav-foot" class="clearfix">
......@@ -32,6 +32,10 @@
</div>
</div>
<div style="display: none" id="session_expired_popup" title="<spring:message code="session.expiry-warning-title" />" >
<div style="margin-bottom: 1em;"><spring:message code="session.expiry-warning" /></div>
<a class="btn btn-primary" href="${pageContext.servletContext.contextPath}"><spring:message code="session.expiry-extend" /></a>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
......@@ -70,4 +74,5 @@
<script type="text/javascript">
L.Icon.Default.imagePath='<c:url value="/html/css/leaflet" />';
enableSessionWarning(${pageContext.session.maxInactiveInterval});
</script>
......@@ -1865,4 +1865,8 @@ html[dir="rtl"] ul.statistics .stats-number {
max-width: 250px;
height: 180px;
margin-top: 0;
}
.no-close .ui-dialog-titlebar-close {
display: none;
}
\ No newline at end of file
......@@ -162,38 +162,62 @@ jQuery(document).ready(function() {
$( document ).ready(function() {
$('#news a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
});
// show mobile menu
$('.mobile-menu-show').click(function(){
$('.mobile-header .header-top .mobile-menu-show').css('display', 'none');
$('.mobile-header .header-top .mobile-menu-hide').css('display', 'inline-block');
$('.logo-container').css('display', 'none');
$('.mobile-header #search').show('slow');
$('#left-col').show('slow');
$('#nav-main').show('slow');
});
$('.mobile-menu-hide').click(function(){
$('.mobile-header .header-top .mobile-menu-show').css('display', 'inline-block');
$('.mobile-header .header-top .mobile-menu-hide').css('display', 'none');
$('.logo-container').css('display', 'block');
$('.mobile-header #search').hide('slow');
$('#left-col').hide('slow');
$('#nav-main').hide('slow');
});
//CSRF protection
$(function () {
var token = $("meta[name='_csrf']").attr("content");
var header = $("meta[name='_csrf_header']").attr("content");
$(document).ajaxSend(function(e, xhr, options) {
xhr.setRequestHeader(header, token);
});
});
$( document ).ready(function() {
$('#news a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
});
// show mobile menu
$('.mobile-menu-show').click(function(){
$('.mobile-header .header-top .mobile-menu-show').css('display', 'none');
$('.mobile-header .header-top .mobile-menu-hide').css('display', 'inline-block');
$('.logo-container').css('display', 'none');
$('.mobile-header #search').show('slow');
$('#left-col').show('slow');
$('#nav-main').show('slow');
});
$('.mobile-menu-hide').click(function(){
$('.mobile-header .header-top .mobile-menu-show').css('display', 'inline-block');
$('.mobile-header .header-top .mobile-menu-hide').css('display', 'none');
$('.logo-container').css('display', 'block');
$('.mobile-header #search').hide('slow');
$('#left-col').hide('slow');
$('#nav-main').hide('slow');
});
//CSRF protection
$(function () {
var token = $("meta[name='_csrf']").attr("content");
var header = $("meta[name='_csrf_header']").attr("content");
$(document).ajaxSend(function(e, xhr, options) {
xhr.setRequestHeader(header, token);
});
});
function enableSessionWarning(secondsBeforeExpiry) {
if ($("#session_expired_popup").length == 0) {
return;
}
$(function () {
$("#session_expired_popup").dialog({
dialogClass: "no-close",
autoOpen: false,
modal: true,
closeOnEscape: false,
show: {
duration: 0
}
});
});
setTimeout(function () {
$("#session_expired_popup").dialog("open");
setTimeout(function() {
$("#session_expired_popup").dialog("close");
}, 60 * 1000);
}, ((secondsBeforeExpiry - 65) * 1000));
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment