From 3200d0ec2981ae63db12ddc14cf0947729878985 Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Fri, 22 Nov 2024 17:59:34 -0500 Subject: [PATCH] Improve session handling --- client/admin/src/app/auth.guard.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/client/admin/src/app/auth.guard.ts b/client/admin/src/app/auth.guard.ts index 77c732b..c8bf95b 100644 --- a/client/admin/src/app/auth.guard.ts +++ b/client/admin/src/app/auth.guard.ts @@ -7,12 +7,16 @@ export const AuthGuard: CanActivateFn = (route, state) => { const authSvc: AuthService = inject(AuthService); if (sessionStorage.getItem('jwt') == null) { let success = false; - authSvc.refresh().subscribe((event) => { - if (event?.status == 200) { - success = true; - } - }); - router.navigate(['/login']); + authSvc.refresh().subscribe( + (event) => { + if (event?.status == 200) { + success = true; + } + }, + (err) => { + router.navigate(['/login']); + }, + ); return success; } else { return true;