| .. | .. |
|---|
| 21 | 21 | } |
|---|
| 22 | 22 | }); |
|---|
| 23 | 23 | |
|---|
| 24 | | - m.factory('securisHttpInterceptor', function($q, $location, $store) { |
|---|
| 24 | + m.factory('securisHttpInterceptor', function($q, $location, $store, toaster) { |
|---|
| 25 | 25 | var isUnauthorizedAccess = function(rejection) { |
|---|
| 26 | | - console.log('rejection -----------------------'); |
|---|
| 27 | | - console.log(rejection); |
|---|
| 28 | 26 | return rejection.status === 401 /* Unauthorized */; |
|---|
| 29 | 27 | } |
|---|
| 30 | 28 | return { |
|---|
| 31 | 29 | '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 | + } |
|---|
| 44 | 45 | return config || $q.when(config); |
|---|
| 45 | 46 | }, |
|---|
| 46 | 47 | 'responseError': function(rejection) { |
|---|