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);
|
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;
|
||||||
|
|
Loading…
Reference in a new issue