GUAC-1161: Do not continue routing if authentication fails.

This commit is contained in:
Michael Jumper
2015-04-21 22:03:45 -07:00
parent 419e936c82
commit dc88c27149

View File

@@ -39,26 +39,17 @@ angular.module('index').config(['$routeProvider', '$locationProvider',
*
* @returns {Promise}
* A promise which resolves successfully only after an attempt to
* re-authenticate has been made.
* re-authenticate has been made. If the authentication attempt fails,
* the promise will be rejected.
*/
var updateCurrentToken = ['$injector', function updateCurrentToken($injector) {
// Required services
var $location = $injector.get('$location');
var $q = $injector.get('$q');
var authenticationService = $injector.get('authenticationService');
// Promise for authentication attempt
var authAttempt = $q.defer();
// Re-authenticate including any parameters in URL
authenticationService.updateCurrentToken($location.search())
['finally'](function authenticationAttemptComplete() {
authAttempt.resolve();
});
// Return promise that will resolve regardless of success/failure
return authAttempt.promise;
return authenticationService.updateCurrentToken($location.search());
}];