benbaran / adal-angular4

Angular 4/5/6/7 ADAL Wrapper
MIT License
87 stars 106 forks source link

ERROR TypeError: "_this.context is null" #93

Closed edleeman closed 5 years ago

edleeman commented 5 years ago

Hi

I'm getting ERROR TypeError: "_this.context is null" when hitting the auth-callback. I believe that _this.context is referring to _this.adal

My callback method public completeAuthentication() { this._adal.handleWindowCallback(); this._adal.getUser().subscribe(user => { console.log(user, 'user'); this._user = user; }); }

Init is called from constructor of my auth service `public init() {

this.configurationService.getBaseUrl().subscribe(res => {
  console.log(res, 'BaseUrl Response');

  var baseUrl = res.value.baseUrl;

  this.configurationService.getAzureConfiguration().subscribe(res => {
    console.log(res, 'AzureConfiguration Response');

    this._config = {
      tenant: res.value.tennantId,
      clientId: res.value.clientId,
      redirectUri: baseUrl + "/auth-callback",
      postLogoutRedirectUri: baseUrl
    }
    console.log(this._config, "Ctor");
    this._adal.init(this._config);
   });
});

}`

My error: image

Worth noting that I'm only seeing this on the callback. The startAuthentication methods work as expected with the correct config values in adal.init

Any help will be greatly appreciated