Admin mode. Data driven content sections. Bugfixes.
This commit is contained in:
1 parent
bd65455945
commit
266c2451f1
30 files changed
+1733
-13
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { CanActivate, Router } from '@angular/router';
|
||||
|
||||
import { AuthService } from '../services/auth.service';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AdminGuard implements CanActivate {
|
||||
private auth = inject(AuthService);
|
||||
private router = inject(Router);
|
||||
|
||||
async canActivate(): Promise<boolean> {
|
||||
// Ensure user info is loaded (handles page-reload race where token
|
||||
// exists but /me hasn't been called yet).
|
||||
const user = await this.auth.getCurrentUser();
|
||||
if (user?.is_admin) {
|
||||
return true;
|
||||
}
|
||||
this.router.navigate(['/login']);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user