Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d79a75d34f |
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user