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);
if (sessionStorage.getItem('jwt') == null) {
let success = false;
authSvc.refresh().subscribe((event) => {
authSvc.refresh().subscribe(
(event) => {
if (event?.status == 200) {
success = true;
}
});
},
(err) => {
router.navigate(['/login']);
},
);
return success;
} else {
return true;