Angular 8 and Okta logout not working as user is redirected inside the app

1.8k views Asked by At

I have implemented Okta authentication in my Angular 8 app. When I hit logout button the session is terminated and I am logged out of Okta app but as my logout URL configured in okta is for localhost:4200/dashboard it redirects me to the dashboard component. Post successful logout I want to navigate user to localhost:4200/login. I have two questions, I tried

 async logOut(){
await this.oauthService.logout();
this.router.navigate(['/login']);
}
// but this does not redirect user to login.

and also, I tried asking Okta support that logout button is in navbar and can be hit from different URLs and not necessarily localhost:4200/dashboard as navbar is on every single page of my application. They mentioned it can only be configured from a single URL path. How can I implement the logout from different components and hence different URL paths.

1

There are 1 answers

0
Gary Archer On

You just need to register a Post Logout Redirect URI and can then trigger logout from any location within your app.

I would implement it like this:

  • Provide a post logout landing page
  • Provide a re-login option on that page

Some resources of mine that might give you some ideas: