[% BLOCK APP_JS %]
<!-- splash / login page app -->
-<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/egLovefield.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/lovefield.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/app.js"></script>
[% END %]
function($q , $scope , $window , $location , $rootScope , egCore , egLovefield , $routeParams , $timeout , $http , ngToast , egConfirmDialog , egUnloadPrompt) {
$scope.active_tab = $routeParams.tab || 'checkout';
+ // Immediately redirect if we're really offline
+ if (!$window.navigator.onLine) {
+ if ($location.path().match(/session$/)) {
+ var path = $location.path();
+ return $location.path(path.replace('session','checkout'));
+ }
+ }
+
var today = new Date();
today.setHours(0);
today.setMinutes(0);
if (token) {
- egNet.request(
- 'open-ils.auth',
- 'open-ils.auth.session.retrieve', token)
-
- .then(function(user) {
- if (user && user.classname) {
- // authtoken test succeeded
- service.user(user);
- service.poll();
- service.check_workstation(deferred);
-
- } else {
- // authtoken test failed
- egHatch.clearLoginSessionItems();
- deferred.reject();
- }
- });
+ if (lf.isOffline && !$location.path().match(/\/session/) ) {
+ // Just stop here if we're in the offline interface but not on the session tab
+ $timeout(function(){deferred.resolve()});
+ } else if (lf.isOffline && $location.path().match(/\/session/) && !$window.navigator.onLine) {
+ // Likewise, if we're in the offline interface on the session tab and the network is down.
+ // The session tab itself will redirect appropriately due to no network.
+ $timeout(function(){deferred.resolve()});
+ } else {
+ // Otherwise, check the token. This will freeze all other interfaces, which is what we want.
+ egNet.request(
+ 'open-ils.auth',
+ 'open-ils.auth.session.retrieve', token)
+
+ .then(function(user) {
+ if (user && user.classname) {
+ // authtoken test succeeded
+ service.user(user);
+ service.poll();
+ service.check_workstation(deferred);
+
+ } else {
+ // authtoken test failed
+ egHatch.clearLoginSessionItems();
+ deferred.reject();
+ }
+ });
+ }
} else {
// no authtoken to test