Fix authGuard
This commit is contained in:
parent
cd75967b4f
commit
3a4c90d12f
2 changed files with 5 additions and 2 deletions
|
@ -5,7 +5,7 @@ import { inject } from '@angular/core';
|
||||||
export const AuthGuard: CanActivateFn = (route, state) => {
|
export const AuthGuard: CanActivateFn = (route, state) => {
|
||||||
const router: Router = inject(Router);
|
const router: Router = inject(Router);
|
||||||
const authSvc: AuthService = inject(AuthService);
|
const authSvc: AuthService = inject(AuthService);
|
||||||
if (localStorage.getItem('jwt') == null) {
|
if (authSvc.token() === null) {
|
||||||
let success = false;
|
let success = false;
|
||||||
authSvc.refresh().subscribe({
|
authSvc.refresh().subscribe({
|
||||||
next: (event) => {
|
next: (event) => {
|
||||||
|
|
|
@ -75,7 +75,10 @@ export class AuthService {
|
||||||
}
|
}
|
||||||
|
|
||||||
_clearState() {
|
_clearState() {
|
||||||
this._state.set(<AuthState>{});
|
this._state.set(<AuthState>{
|
||||||
|
is_auth: false,
|
||||||
|
token: null,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue