benbaran / adal-angular4

Angular 4/5/6/7 ADAL Wrapper
MIT License
86 stars 104 forks source link

On handlewindowcallback not applying idtoken being sent #36

Open Milad0207 opened 6 years ago

Milad0207 commented 6 years ago

So just to clarify this was working 1-2 weeks ago and I updated version to 2.0.14 and caused another issue that broken whole system so reverted back to 2.0.13 and now my authentication will not get applied after my idtoken is returned with the url and handlewindowcallback is called but the service doesn't see the token or still marked as not authenticated. I do see the service trying to deserialize the token but not sure why it's not working. Is it related to the adal.js version upgrading as well?

Anyone see a similar issue

largeDachshund commented 6 years ago

i'm trying to mirror the adal-angular4-example. In the toolbar's ngOnInit() - this._adalService.handleWindowCallback(); the context is null in the service.

Milad0207 commented 6 years ago

so when I ran into this issue I ended up switching to Adal-angular5 instead of adal-angular4 but they both ran into the same issue, then I was able to fix this issue by reverting back to angular 5.24, because before it auto upgraded me to 5.2.8 which was the cause of this bug, so I recommend you downgrade your angular version down as I did have Adal-angular4 working when I was using 5.2.4 before so I assume the upgraded version has a bug that's breaking it and needs to be fixed.

geerzo commented 6 years ago

Is this still an issue?

Milad0207 commented 6 years ago

I haven't upgraded angular yet, so I have not tested if this was fixed with the newer versions.

geerzo commented 6 years ago

Do me a favor and try 2.0.16. I believe the issue you are seeing is due to the fact that adal-angular was updated to 1.0.16 in 2.0.14 but was downgraded back down to 1.0.15 later.

Milad0207 commented 6 years ago

any specific versions of what you want me to test out? want me to upgrade angular and to which version? and want me to upgrade the adal-angular5 library I have cause I'm not using adal-angular4 anymore

I can't promise to do it right now but i can try it out when i find some time.

geerzo commented 6 years ago

2.0.16 is the latest version for angular 5.x

Milad0207 commented 6 years ago

I tried Upgrading to 2.0.16 and using 5.2.10 and but having a different issue. I get this when I run it, not sure the problem, I don't have this issue with adal-angular5 which i'm aware is behing on some changes that this library has applied.

NodeInvocationException: Prerendering failed because of error: ReferenceError: window is not defined at eval (webpack-internal:///617:177:5) at eval (webpack-internal:///617:1664:2)

geerzo commented 6 years ago

Ok, I don't have a way to test 5.x at the moment. Let me see if I can remedy that.

MagnusKnalstad commented 6 years ago

Everything worked fine with Angular 5.2.4 using the Adal-angualr5 wrapper. When upgrading to Angular 6.X and the 3+ versions of this library I am running into the same issue. Somehow, It works sometimes and I receive all information from the the callback around 2 / 10 times. (Spam clicking) Very strange. Hope it will be fixed soon. I have to revert back to Angular 5 as well

geerzo commented 6 years ago

@MagnusKnalstad I'm not sure I understand your issue. adal-angular5 is a different project so there could be changes there not compatible here. Just speculating.

Take a look at the example app as it's a working example of Angular 6 with 3.0.7. https://github.com/benbaran/adal-angular6-example

MagnusKnalstad commented 6 years ago

Hi again and thanks for fast feedback @geerzo . The Adal-angular5 was just a fork that was based on this repo. Cool, I will take a look. My issue has been when upgrading, I could see the token being fetched in the url, but somehow when the handleWindowCallback was being called, everything got flushed. (Tested yeserday with the 3.0.7 version). When inspecting the adal.userInfo everything is set to null.

Anyway, if it is a working example with Angular 6 and 3.0.7, I shall take a closer look to figure out if there's any other root to the problem conflicting here. It seemed very similar to the issue that was posted here.

Thanks again

geerzo commented 6 years ago

@MagnusKnalstad make sure you haven't included a newer version of adal-angular. We are currently hardcoded to 1.0.15 because changes in >=1.0.16 aren't compatible with this project and give similar results to what you described. I'm hoping to investigate that at some point but it's been elusive.

Milad0207 commented 6 years ago

How do i hardcode 1.0.15 library for adal-angular, the adal-angular4 is setup to use the 1.0.16 version