This commit is contained in:
2026-03-15 12:50:33 +01:00
parent dd68a6b21d
commit d907c89eb6
36 changed files with 309 additions and 286 deletions

View File

@@ -2,7 +2,7 @@ import {Injectable, inject} from '@angular/core';
import {ActivatedRouteSnapshot, Router, UrlTree} from '@angular/router';
import {Observable} from 'rxjs';
import {UserService} from '../../services/user/user.service';
import {map} from 'rxjs/operators';
import {map, take} from 'rxjs/operators';
@Injectable({
providedIn: 'root',
@@ -18,8 +18,11 @@ export class RoleGuard {
}
return this.userService.user$.pipe(
take(1),
map(user => {
if (!user) return false;
if (!user) {
return this.router.createUrlTree(['brand', 'new-user']);
}
const roles = user.role?.split(';') ?? [];
if (roles.indexOf('admin') !== -1) {
return true;