From e5c397668b47187c3dcddc2bb82627c92584a2d3 Mon Sep 17 00:00:00 2001 From: Art Date: Sun, 12 Sep 2021 12:10:15 +0300 Subject: [PATCH] 101. Logout (#12) --- .../src/app/service/authentication.service.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/support-portal-frontend/src/app/service/authentication.service.ts b/support-portal-frontend/src/app/service/authentication.service.ts index 60257e0..789b9ac 100644 --- a/support-portal-frontend/src/app/service/authentication.service.ts +++ b/support-portal-frontend/src/app/service/authentication.service.ts @@ -11,6 +11,9 @@ import {User} from "../model/user"; export class AuthenticationService { private host: string = environment.apiUrl; + private token: string | null; + private loggedInUser: string | null; + private storage = localStorage; constructor(private httpClient: HttpClient) { } @@ -25,4 +28,11 @@ export class AuthenticationService { .post(`${this.host}/user/register`, user); } + public logout(): void { + this.token = null; + this.loggedInUser = null; + this.storage.removeItem("jwt-token"); + this.storage.removeItem("user"); + this.storage.removeItem("users"); + } }