Open jycaraujo opened 5 years ago
@jycaraujo Can you provide more context to your error? Where are you calling login?
Here is some of my working code:
export class AppComponent implements OnInit {
constructor(private configService: ConfigurationService, public adalService: AdalService) {
this.adalService.init(this.configService.get(c => c.aadConfig))
}
ngOnInit(): void {
this.adalService.handleWindowCallback(true)
}
@michaeltarleton my working code is very similar to yours
export class AppComponent implements OnInit {
constructor(private adalSvc: AdalService) {
this.adalSvc.init(environment.adalConfig);
}
ngOnInit(): void {
this.adalSvc.handleWindowCallback(); //error line
}
}
and this is my login component:
export class LoginComponent implements OnInit {
loading: boolean;
constructor(
private route: ActivatedRoute,
private router: Router,
private adalSvc: AdalService
) {
}
ngOnInit() {
const returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
if (this.adalSvc.userInfo.authenticated) {
this.router.navigate([returnUrl]);
}
}
login() {
this.loading = true;
this.adalSvc.login();
}
}
What does your production environment file look like? The only reason you would get that error is if there was another error during the constructor that I can see.
Just had a similar issue, documenting for future users with this issue, fixed it by going back to my previous wotking code and noticing I forgot to init adal with the required configuration before using it.
Just add this line before everything happens, I have added in init of app.component.ts
adalService.init(environment.adalConfig);
Then check your environment for adalConfig:
adalConfig: { tenant: 'REDACTED', clientId: 'REDACTED', endpoints: { 'https://graph.microsoft.com': '00000003-0000-0000-c000-000000000000' } }
Hi, I implemented a login component with "@angular/cli": "~6.2.3" and "adal-angular4": "^3.0.16", it works fine in DEV/UAT environment but when I migrated to PROD I received the following error:
Does anyone know how to fix it? Thanks.