Explorar o código

If logged out from another tab - handle accordingly

Vijayakrishnan %!s(int64=4) %!d(string=hai) anos
pai
achega
55da7976d6
Modificáronse 1 ficheiros con 3 adicións e 5 borrados
  1. 3 5
      public/js/mc.js

+ 3 - 5
public/js/mc.js

@@ -189,6 +189,9 @@ function onFastLoaded(_data, _href, _history) {
             case 500:
                 msg = 'Error on page: ';
                 break;
+            case 0: // not logged in - refresh top level window to go to login
+                window.top.location = '/';
+                break;
         }
         console.warn('MC: Target page failed: ' + _href);
         targetParent.html('<p class="text-danger p-3 small"><b>' + _data + '</b> - ' + msg + '<b>' + _href + '</b></p>');
@@ -223,11 +226,9 @@ function fastLoad(_href, _history = true, _useCache = true, _replaceState = fals
         if (target[0] === '/') target = target.substr(1);
         if (_replaceState) {
             window.top.history.replaceState(target, null, '/mc/' + target);
-            // console.log('ALIX replaceState: [' + target + ']');
         }
         else {
             window.top.history.pushState(target, null, '/mc/' + target);
-            // console.log('ALIX pushState: [' + target + ']');
         }
     }
 
@@ -237,9 +238,6 @@ function fastLoad(_href, _history = true, _useCache = true, _replaceState = fals
         $.get(_href, function (_data) {
             onFastLoaded(_data, _href, _history);
         }).fail(function (_jqXhr) {
-            // if(_jqXhr.status === 403) {
-            //     alert('You do not have access to this patient.');
-            // }
             onFastLoaded(_jqXhr.status, _href, _history);
         });
     }