I am using auth0 to configure my Angular 17 app with an Auth0 AuthGuard. If you enter the site and the user is not logged in via auth0 then it redirects you straight to auth0s Login Page, which is fine. But after login/sign up it just redirects you back to the “last time you logged in with” screen. It doesn’t matter how many times I enter it, it just keeps looping back to this page. Im not even getting an error or anything, it just redirects back to the login page within a second or two.
It works perfectly fine on my DEV site and locally but for some reason, production is not working. I can supply a HAR file if needed.
app.module.ts
imports: [
other modules....
AuthModule.forRoot(environment.auth0)
],
environment.ts
auth0: {
domain: 'golftech.us.auth0.com',
clientId: 'WILL SUPPLY IF NEEDED',
authorizationParams: {
redirect_uri: window.location.origin + '/index.html',
audience: 'https://logical-prod/api'
},
httpInterceptor: {
allowedList: [
'https://golftech-prod-appsvc-main-api.azurewebsites.net/api/*',
'https://golftech-prod-appsvc-identity.azurewebsites.net/api/*']
}
}
app-routing.module.ts
path: '',
component: PostLoginLayoutComponent,
canActivateChild: [AuthGuard],
children: [
{ path: '', redirectTo: '/dashboard', pathMatch: 'full'},
{ path: 'dashboard', component: DashboardComponent},
postlogin-layout.component.ts
ngOnInit() {
if (!this.sessionService.isUserLoggedIn()) {
this.isLoading = true;
console.log("before auth0 service call");
this.authService.user$.subscribe(result => {
console.log("auth0: " + result);
this.identityService.getUserByAuth0Id(result.sub).subscribe(user => {
this.user = user;
this.isLoading = false;
this.sessionService.setUser(this.user);
this.globalDataService.postLoginEvent.emit();
this.checkIfOutingIsSelected();
}, err => {
this.isLoading = false;
console.log(err);
})
});
} else {
console.log("invalid login");
this.user = this.sessionService.getUser();
this.checkIfOutingIsSelected();
}
}