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

Commit

Permalink
Experiment in token refresh.
Browse files Browse the repository at this point in the history
Leave logs for testing on preview.
  • Loading branch information
Simone Duca committed Feb 2, 2018
1 parent df70a20 commit fb59994
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
25 changes: 20 additions & 5 deletions app/modules/auth/auth.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,35 @@ require('./auth.module.js')
.factory('authFactory', authFactory);

var OAuth = require('panoptes-client/lib/oauth');
var Auth = require('panoptes-client/lib/auth');

// @ngInject
function authFactory($interval, $timeout, $location, $window, localStorageService, ModalsFactory, zooAPI, zooAPIConfig, CribsheetFactory, $rootScope) {

var factory;

var _user = {};
// 2 hrs
var timeout = 120 * 60 * 1000;

$timeout( function() {
Auth.checkBearerToken()
.then(function (token) {
console.log('Token refreshed: ', token);
})
.catch(function (error) {
console.log('Failed to refresh token: ', error);
factory.signOut;
})
}, 10000); // 20 sec, just for testing. Swap with timeout variable when I get this to work


OAuth.checkCurrent()
.then(function (user) {
if (user) {
_setUserData();
}
});
.then(function (user) {
if (user) {
_setUserData();
}
});

factory = {
signIn: signIn,
Expand Down
2 changes: 1 addition & 1 deletion gulp/tasks/browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function buildScript(file) {
.pipe(gulpif(createSourcemap, sourcemaps.init()))
.pipe(gulpif(global.isProd, streamify(
uglify({
compress: { drop_console: true }
compress: { } // leave console.log in prod, for testing
})
.on('error', handleErrors)
)))
Expand Down

0 comments on commit fb59994

Please sign in to comment.