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

Commit

Permalink
Merge pull request #631 from mottykohn/dev
Browse files Browse the repository at this point in the history
A hacky fix for #574
  • Loading branch information
rohitnarula7176 authored Nov 2, 2017
2 parents 37cf397 + b0d609e commit 288b651
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/adal-angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,11 @@
};

var stateChangeErrorHandler = function (event, toState, toParams, fromState, fromParams, error) {
_adal.verbose("State change error occured. Error: " + JSON.stringify(error));
_adal.verbose("State change error occured. Error: " + typeof(error) === 'string'? error: JSON.stringify(error));

// adal interceptor sets the error on config.data property. If it is set, it means state change is rejected by adal,
// in which case set the defaultPrevented to true to avoid url update as that sometimesleads to infinte loop.
if (error && error.data) {
if (error && error.data && event) {
_adal.info("Setting defaultPrevented to true if state change error occured because adal rejected a request. Error: " + error.data);
event.preventDefault();
}
Expand All @@ -313,6 +313,12 @@
$rootScope.$on('$locationChangeStart', locationChangeHandler);

$rootScope.$on('$stateChangeError', stateChangeErrorHandler);

if ($injector.has('$transitions')) {
var $transitions = $injector.get('$transitions');
$transitions.onStart({}, (transition) => stateChangeHandler(null, transition.to()));
$transitions.onError({}, (transition) => stateChangeErrorHandler(null, null, null, null, null, transition.error()));
}

//Event to track hash change of
$window.addEventListener('adal:popUpHashChanged', function (e) {
Expand Down

0 comments on commit 288b651

Please sign in to comment.