Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Commit

Permalink
Update logout view if token refresh fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Duca committed Feb 12, 2018
1 parent c1af7da commit 77b44b6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/modules/zoo-api/zooapi.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ 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) {
console.log('Token refreshed: ', token);
})
.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
Expand Down

0 comments on commit 77b44b6

Please sign in to comment.