From fc74fe4efff8d21a251091577c46839476f6525b Mon Sep 17 00:00:00 2001 From: FlayInAHook Date: Wed, 18 Nov 2020 17:51:04 +0100 Subject: [PATCH] storing email in local storage --- src/app/services/auth.service.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 46aaae0..1d498af 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -11,6 +11,7 @@ export class AuthService { public loggedIn: BehaviorSubject; private readonly REQUEST_TOKEN = 'requestToken'; private readonly REFRESH_TOKEN = 'refreshToken'; + private readonly EMAIL = 'email'; constructor(private http: HttpClient) { this.loggedIn = new BehaviorSubject(false); @@ -37,6 +38,7 @@ export class AuthService { // store request and refresh token in local storage to keep user logged in between page refreshes this.storeTokens(response); this.checkIfUserIsLoggedIn(); + this.storeEmail(email); }) ); } @@ -55,6 +57,14 @@ export class AuthService { ); } + storeEmail(email: string) { + localStorage.setItem(this.EMAIL, email); + } + + getEmail() { + localStorage.getItem(this.EMAIL); + } + refreshToken() { return this.http .post(`${environment.authUrl}/new-token`, { @@ -87,5 +97,6 @@ export class AuthService { private removeTokens() { localStorage.removeItem(this.REQUEST_TOKEN); localStorage.removeItem(this.REFRESH_TOKEN); + localStorage.removeItem(this.EMAIL) } }