fix: auth guard

This commit is contained in:
eneller
2026-04-11 01:40:37 +02:00
parent 38dedfc829
commit d79a75d34f
3 changed files with 7 additions and 6 deletions

View File

@@ -20,15 +20,15 @@ export class App implements OnInit{
active = '/';
constructor(
private router: Router
private router: Router,
){}
ngOnInit(): void {
// show correct active tab
this.router.events
.pipe(filter(event => event instanceof NavigationEnd))
.subscribe(() =>{
this.active = this.router.url;
console.log(this.active);
});
}

View File

@@ -1,14 +1,14 @@
import { inject } from '@angular/core';
import { CanActivateFn, Router } from '@angular/router';
import { APIService } from './api';
import { map } from 'rxjs/operators';
import { first, map } from 'rxjs/operators';
export const authGuard: CanActivateFn = (route, state) => {
const api = inject(APIService);
const router = inject(Router);
//FIXME always redirected to login after page load
return api.isAuthenticated$.pipe(
return api.checkAuthStatus().pipe(
first(),
map((isAuthenticated) => {
if (isAuthenticated) {
return true;