From e33f49f7ec8c3682280b73d76708286f89c77aa0 Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Date: Tue, 29 Aug 2023 02:17:49 -0300 Subject: [PATCH] Implements Automatic Profile Image Reload Automatically reloads image after Add Profile Image operation --- src/app/shared/auth/auth.service.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/shared/auth/auth.service.ts b/src/app/shared/auth/auth.service.ts index de9a73b..9d3bf68 100644 --- a/src/app/shared/auth/auth.service.ts +++ b/src/app/shared/auth/auth.service.ts @@ -46,6 +46,10 @@ export class AuthService { } + refresh(): void { + this.validateUser(this.refreshAccessToken()); + } + autoLogin(): void { this.validateUser(this.validateSession()); } @@ -68,7 +72,11 @@ export class AuthService { (response: Observable) => { response.subscribe({ next: (response: any) => { - this.processProfilePicture().subscribe(); + this.processProfilePicture().subscribe( + () => { + this.refresh(); + } + ); } }); } @@ -146,11 +154,11 @@ export class AuthService { } private refreshAccessToken() { - return firstValueFrom(this.http.post( + return this.http.post( this.BACKEND_PATH + "/user/login/refresh", this.userAuthenticated.refreshToken, { withCredentials: true } - )); + ); } private validateSession(): Observable {