sureshchahal / angular2-adal

Angular 2 wrapper for adal.js
MIT License
41 stars 50 forks source link

aquireToken breaks bindings #15

Open IoBebe opened 7 years ago

IoBebe commented 7 years ago

Issue

I was playing around with angular2 and adal and found this scenario where using aquire token causes bindings to Observable<any[]> to not work.

I've uploaded a sample of what I found here.

I don't claim to be very knowledgeable in these things, there is a high chance i am might be doing something wrong.

In Short:

Adal uses an IFrame to make fetch the token, the whole angular2 app is loaded in that IFrame. I suspect that interferes with the binding. My example shows 3 bindings:

  1. a list binded to Observable<any[]> using async with an aquire token requst
  2. a list binded to Observable<any[]> using async and NO aquire token request
  3. a list binded to string[] with an aquire token request

Scenarios

1.Open a new tab

On opening the app, after the authentication step and the redirect back to the /oic route, the 3 bidings from above behave in the following way:

  1. does not work
  2. works
  3. works only if the manual refresh ChangeDetectorRef.detectChanges() is in place

(you can also see in the console that the app is loaded in the IFrame as well.)

2.Refresh

On refreshing the app, having the token cached, there is no redirect to the /oic route and the 3 bindings behave in the following way:

  1. works
  2. works
  3. works (regardless of the manual refresh)
nikhil263 commented 7 years ago

Even I'm seeing the same behavior. Don't know how to work around this issue.