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;

View File

@@ -9,7 +9,8 @@
"test": "echo \"Error: no test specified\" && exit 1",
"server": "npm run dev --workspace=server",
"client": "npm start --prefix client",
"dev": "concurrently \"npm run server\" \"npm run client\""
"dev": "concurrently \"npm run server\" \"npm run client\"",
"teardown": "npm run teardown --workspace=server"
},
"workspaces": [
"client",