Improve session handling
This commit is contained in:
parent
be8d96d7e5
commit
3200d0ec29
1 changed files with 10 additions and 6 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue