From 68bb8dcac1d9c90dbb22daef039e2e001160fadc Mon Sep 17 00:00:00 2001 From: jggoebel <86782124+jggoebel@users.noreply.github.com> Date: Wed, 26 Oct 2022 21:13:05 +0200 Subject: [PATCH] Logout if token expires (#135) --- src/app/header/header.component.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts index 29238f71..b13ca8b1 100644 --- a/src/app/header/header.component.ts +++ b/src/app/header/header.component.ts @@ -56,6 +56,10 @@ export class HeaderComponent implements OnInit { var tok = this.helper.decodeToken(this.helper.tokenGetter()); this.email = tok.email; + + // Automatically logout the user after token expiration + const timeout = tok.exp - Date.now(); + setTimeout(() => this.doLogout(), timeout); } @ViewChild("logoutmodal", { static: true }) logoutModal: ClrModal;