From 77b44b6193827c5c43604b78353b45d739d92bec Mon Sep 17 00:00:00 2001 From: Simone Duca Date: Mon, 12 Feb 2018 16:07:34 +0000 Subject: [PATCH] Update logout view if token refresh fails. --- app/modules/zoo-api/zooapi.factory.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/modules/zoo-api/zooapi.factory.js b/app/modules/zoo-api/zooapi.factory.js index d84592e..40ce96d 100644 --- a/app/modules/zoo-api/zooapi.factory.js +++ b/app/modules/zoo-api/zooapi.factory.js @@ -6,7 +6,7 @@ require('./zooapi.module.js') var ApiClient = require('panoptes-client/lib/api-client'); var OAuth = require('panoptes-client/lib/oauth') // @ngInject -function zooAPI(zooAPIConfig) { +function zooAPI($rootScope, zooAPIConfig) { ApiClient.beforeEveryRequest = function() { return OAuth.checkBearerToken() .then(function (token) { @@ -14,7 +14,9 @@ function zooAPI(zooAPIConfig) { }) .catch(function (error) { console.log('Failed to refresh token: ', error); - factory.signOut; + alert('Your session has finished. Please save your work and login again.') + $rootScope.$broadcast('auth:loginChange'); + OAuth.signOut(); }) } // There's only a version of this project on production, so rather than