mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
feat: reflect django permissions on UI
This commit is contained in:
23
src-ui/src/app/guards/auth.gard.ts
Normal file
23
src-ui/src/app/guards/auth.gard.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
CanActivate,
|
||||
ActivatedRouteSnapshot,
|
||||
RouterStateSnapshot,
|
||||
} from '@angular/router'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { SettingsService } from '../services/settings.service'
|
||||
|
||||
@Injectable()
|
||||
export class AuthGard implements CanActivate {
|
||||
constructor(public settingsService: SettingsService) {}
|
||||
|
||||
canActivate(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot
|
||||
): boolean {
|
||||
var canActivate = false
|
||||
this.settingsService.permissions().subscribe((perm) => {
|
||||
canActivate = perm.includes(route.data.requiredPermission)
|
||||
})
|
||||
return canActivate
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user