first draft

This commit is contained in:
2026-06-09 17:36:46 +02:00
parent 6c385aebe4
commit 9df03fba90
46 changed files with 29915 additions and 498 deletions

15
src/app/auth-guard.ts Normal file
View File

@@ -0,0 +1,15 @@
import { inject, Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
import { environment } from '../environments/environment';
@Injectable()
export class AuthGuard implements CanActivate {
private readonly router = inject(Router);
canActivate(_route: ActivatedRouteSnapshot, _state: RouterStateSnapshot): boolean {
const token = environment.apiKey??localStorage.getItem('api-key');
if (!environment.production && !token)
this.router.navigate(['login'], { queryParams: { redirectTo: btoa(window.location.pathname + window.location.search) } });
return true;
}
}