Skip to content

Commit

Permalink
Logout on unauth
Browse files Browse the repository at this point in the history
  • Loading branch information
joanagmaia committed Jul 20, 2023
1 parent 6d1c463 commit c25377a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions frontend/src/middleware/auth/unauth-guard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AuthToken } from '@/modules/auth/auth-token';
import AuthCurrentTenant from '@/modules/auth/auth-current-tenant';
import { Auth0Service } from '@/shared/services/auth0.service';

/**
* Unauth Guard
Expand All @@ -18,6 +19,12 @@ export default function ({ to, router }) {
return;
}

Auth0Service.isAuthenticated().then((isAuthenticated) => {
if (!isAuthenticated) {
Auth0Service.logout();
}
});

const token = AuthToken.get();
const tenantId = AuthCurrentTenant.get();

Expand Down
4 changes: 4 additions & 0 deletions frontend/src/shared/services/auth0.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class Auth0ServiceClass {
this.webAuth.loginWithRedirect();
}

isAuthenticated() {
return this.webAuth.isAuthenticated();
}

public async handleAuth(): Promise<void> {
return this.webAuth.handleRedirectCallback()
.then(() => this.webAuth.getIdTokenClaims())
Expand Down

0 comments on commit c25377a

Please sign in to comment.