Fix authGuard

This commit is contained in:
Daniel Ponte 2025-02-09 10:03:52 -05:00
parent cd75967b4f
commit 3a4c90d12f
2 changed files with 5 additions and 2 deletions

View file

@ -5,7 +5,7 @@ import { inject } from '@angular/core';
export const AuthGuard: CanActivateFn = (route, state) => {
const router: Router = inject(Router);
const authSvc: AuthService = inject(AuthService);
if (localStorage.getItem('jwt') == null) {
if (authSvc.token() === null) {
let success = false;
authSvc.refresh().subscribe({
next: (event) => {

View file

@ -75,7 +75,10 @@ export class AuthService {
}
_clearState() {
this._state.set(<AuthState>{});
this._state.set(<AuthState>{
is_auth: false,
token: null,
});
}
logout() {