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

adal.js doesn't works with ui-router release 1 #574

Closed
mpellerin42 opened this issue Jun 16, 2017 · 10 comments
Closed

adal.js doesn't works with ui-router release 1 #574

mpellerin42 opened this issue Jun 16, 2017 · 10 comments
Milestone

Comments

@mpellerin42
Copy link

I spent few hours to try to have ADAL working with my app but even though my configuration seems to be good, the redirection to the authentication page is never triggered.
So I took a look into adal-angular.js and I found that it relies on events which are not triggered by ui-router release 1:

                // Route change event tracking to receive fragment and also auto renew tokens
                $rootScope.$on('$routeChangeStart', routeChangeHandler);

                $rootScope.$on('$stateChangeStart', stateChangeHandler);

                $rootScope.$on('$locationChangeStart', locationChangeHandler);

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

UI-router release 1 use transition hooks now. That would be great to have a version of adal-angular.js compatible with UI-router 1 now it has been released.

@gfsarri
Copy link

gfsarri commented Sep 20, 2017

I'm also having problems between ui-router (old version, < 1.x) and ADAL. In my case what I can see is that there must be some kind of issue between the ui-router navigation and the attempt to request Azure the navigation token (window.location.replace(urlNavigate); inside AuthenticationContext.prototype.promptUser in adal.js).

In case it can help somebody, the following workaround has worked for me: set to false requireADLogin in the ui-router state and, after the state has loaded, call explicitly from the controller the public adalAuthenticationService.login() method.

mottykohn added a commit to mottykohn/azure-activedirectory-library-for-js that referenced this issue Sep 28, 2017
It works but obviously could be better. Just sharing for the interim.
@AmitOlkar
Copy link

Any updates on fixing this ? My project is also being held back due to this issue.

@gfsarri
Copy link

gfsarri commented Oct 3, 2017 via email

@mottykohn
Copy link
Contributor

The root cause is a deprecated event listener in adal-angular.js. It listens to $stateChangeStart and $stateChangeError which have been deprecated. see https://ui-router.github.io/guide/ng1/migrate-to-1_0#state-change-events. See PR #631 for a simple workaround that works for me. (Although as it is titled its hacky.)

@navyasric navyasric added this to the 1.0.16 milestone Oct 5, 2017
@rdkleine
Copy link

rdkleine commented Oct 16, 2017

+1 @mottykohn your PR works for me. Now waiting for 1.0.16 😄

@sayush
Copy link

sayush commented Oct 27, 2017

@mottykohn the PR works for me as well till the token expires. The token does not get renewed for some reason. Has any body faced this?

@mottykohn
Copy link
Contributor

@sayush Looked over code and cannot figure out why this would happen. Never faced this.

@mottykohn
Copy link
Contributor

@sayush does your problem have something to do with #644?

@sayush
Copy link

sayush commented Oct 30, 2017

@mottykohn sorry, it was nothing to do with the library. Everything to do with my code. I was accidentally sending a wrong url (eg. blah.blah/home instead of blah.blah) while trying to renew the token. It wasn't giving me any detailed error message so took a while to figure out. Thanks for the prompt response.

@rohitnarula7176
Copy link
Contributor

rohitnarula7176 commented Nov 2, 2017

@mottykohn Thank you for the pull request. I merged your changes and added the definition for transition events on top of it. @mathilde-pellerin @sayush @rdkleine @gfsarri @AmitOlkar The library should now work with ui router >1.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants