Improve session handling

This commit is contained in:
Daniel Ponte 2024-11-22 17:59:34 -05:00
parent be8d96d7e5
commit 3200d0ec29

View file

@ -7,12 +7,16 @@ export const AuthGuard: CanActivateFn = (route, state) => {
const authSvc: AuthService = inject(AuthService); const authSvc: AuthService = inject(AuthService);
if (sessionStorage.getItem('jwt') == null) { if (sessionStorage.getItem('jwt') == null) {
let success = false; let success = false;
authSvc.refresh().subscribe((event) => { authSvc.refresh().subscribe(
if (event?.status == 200) { (event) => {
success = true; if (event?.status == 200) {
} success = true;
}); }
router.navigate(['/login']); },
(err) => {
router.navigate(['/login']);
},
);
return success; return success;
} else { } else {
return true; return true;