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

Commit

Permalink
Signal the user session is finished before logging them out.
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Duca committed Feb 12, 2018
1 parent c1af7da commit 2a685ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 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,16 @@ 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(zooAPIConfig, authFactory) {
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.')
authFactory.signOut;
})
}
// There's only a version of this project on production, so rather than
Expand Down
4 changes: 3 additions & 1 deletion app/modules/zoo-api/zooapi.module.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict';

module.exports = require('angular')
.module('app.zooapi', []);
.module('app.zooapi', [
'app.auth'
]);

0 comments on commit 2a685ef

Please sign in to comment.