Roberto Sánchez
2014-01-23 cbfe9207ad7c9bba96b39c550d250d12097fd06f
securis/src/main/resources/static/js/main.js
....@@ -21,26 +21,27 @@
2121 }
2222 });
2323
24
- m.factory('securisHttpInterceptor', function($q, $location, $store) {
24
+ m.factory('securisHttpInterceptor', function($q, $location, $store, toaster) {
2525 var isUnauthorizedAccess = function(rejection) {
26
- console.log('rejection -----------------------');
27
- console.log(rejection);
2826 return rejection.status === 401 /* Unauthorized */;
2927 }
3028 return {
3129 'request': function(config) {
32
- var la = $store.get('last_access');
33
- var now = new Date().getTime();
34
- if (la !== null) {
35
- if (now > (la + 1800000)) { // Session timeout is 1/2 hour
36
- $store.clear();
37
- $location.path('/login');
38
- BootstrapDialog.alert('Session has expired');
39
- } else {
40
- console.log('Last access recent');
41
- }
42
- }
43
- $store.set('last_access', now);
30
+ var token = $store.get('token');
31
+ if (token) {
32
+ var la = $store.get('last_access');
33
+ var now = new Date().getTime();
34
+ if (la !== null) {
35
+ if (now > (la + 1800000)) { // Session timeout is 1/2 hour
36
+ $store.clear();
37
+ $location.path('/login');
38
+ toaster.pop('warning', 'Session has expired', null, 4000);
39
+ } else {
40
+ console.log('Last access recent');
41
+ }
42
+ }
43
+ $store.set('last_access', now);
44
+ }
4445 return config || $q.when(config);
4546 },
4647 'responseError': function(rejection) {