mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-08 21:15:09 +00:00
Permissions service
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { Injectable, signal } from '@angular/core'
|
||||
import { ObjectWithPermissions } from '../data/object-with-permissions'
|
||||
import { User } from '../data/user'
|
||||
|
||||
@@ -39,16 +39,19 @@ export enum PermissionType {
|
||||
export class PermissionsService {
|
||||
private permissions: string[]
|
||||
private currentUser: User
|
||||
private permissionsVersion = signal(0)
|
||||
|
||||
public initialize(permissions: string[], currentUser: User) {
|
||||
this.permissions = permissions
|
||||
this.currentUser = currentUser
|
||||
this.permissionsVersion.update((version) => version + 1)
|
||||
}
|
||||
|
||||
public currentUserCan(
|
||||
action: PermissionAction,
|
||||
type: PermissionType
|
||||
): boolean {
|
||||
this.permissionsVersion()
|
||||
return (
|
||||
this.currentUser?.is_superuser ||
|
||||
this.permissions?.includes(this.getPermissionCode(action, type))
|
||||
|
||||
Reference in New Issue
Block a user