From a6d64b1747938b0a4899787d18ca50372c1c7ada Mon Sep 17 00:00:00 2001 From: Sercan Yemen <117369+srcn@users.noreply.github.com> Date: Tue, 24 May 2022 12:42:23 +0300 Subject: [PATCH] (auth) Made the renewing token on "sign-in-with-token" process an optional step to simplify the login process --- src/app/core/auth/auth.service.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index e4bb1001..5cce7676 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -107,8 +107,17 @@ export class AuthService ), switchMap((response: any) => { - // Store the access token in the local storage - this.accessToken = response.accessToken; + // Replace the access token with the new one if it's available on + // the response object. + // + // This is an added optional step for better security. Once you sign + // in using the token, you should generate a new one on the server + // side and attach it to the response object. Then the following + // piece of code can replace the token with the refreshed one. + if ( response.accessToken ) + { + this.accessToken = response.accessToken; + } // Set the authenticated flag to true this._authenticated = true;