| .. | .. |
|---|
| 28 | 28 | return rejection.status === 401 /* Unauthorized */; |
|---|
| 29 | 29 | } |
|---|
| 30 | 30 | return { |
|---|
| 31 | | - |
|---|
| 31 | + '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); |
|---|
| 44 | + return config || $q.when(config); |
|---|
| 45 | + }, |
|---|
| 32 | 46 | 'responseError': function(rejection) { |
|---|
| 33 | 47 | // do something on error |
|---|
| 34 | 48 | if (isUnauthorizedAccess(rejection)) { |
|---|