Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions ui/src/app/security/support/security.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,27 @@ export class SecurityGuard implements CanActivate {
const featureNeeded: string = route.data.feature;
if (featureNeeded) {
if ((await this.aboutService.isFeatureEnabled(featureNeeded)) === false) {
this.router.navigate(['feature-disabled']);
await this.router.navigate(['feature-disabled']);
}
}

const canAccess = await this.securityService.canAccess(rolesNeeded);
if (canAccess) {
// Check if the role requirements are met.
if (await this.securityService.canAccess(rolesNeeded)) {
return true;
}
const securityEnabled = await this.securityService.securityEnabled().pipe(take(1)).toPromise();
if (securityEnabled) {
const loggedInUser = await this.securityService.loggedinUser().pipe(take(1)).toPromise();
if (loggedInUser) {
this.router.navigate(['roles-missing']);
} else {
this.router.navigate(['authentication-required']);
}
} else {

// Check if security is disabled.
if (!(await this.securityService.securityEnabled().pipe(take(1)))) {
return true;
}

// Check if the user is authenticated, otherwise navigate to authentication / role missing page.
if (await this.securityService.loggedinUser().pipe(take(1))) {
await this.router.navigate(['roles-missing']);
} else {
await this.router.navigate(['authentication-required']);
}

return false;
}
}