mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-07 15:25:41 +01:00
Dont perform permissions queries by default
This commit is contained in:
parent
15fb3e5328
commit
88a5a2049b
10 changed files with 117 additions and 19 deletions
|
|
@ -58,17 +58,24 @@ export class PermissionsService {
|
|||
action: string,
|
||||
object: ObjectWithPermissions
|
||||
): boolean {
|
||||
let actionObject = null
|
||||
if (action === PermissionAction.View) actionObject = object.permissions.view
|
||||
else if (action === PermissionAction.Change)
|
||||
actionObject = object.permissions.change
|
||||
if (!actionObject) return false
|
||||
return (
|
||||
this.currentUserOwnsObject(object) ||
|
||||
actionObject.users.includes(this.currentUser.id) ||
|
||||
actionObject.groups.filter((g) => this.currentUser.groups.includes(g))
|
||||
.length > 0
|
||||
)
|
||||
if (action === PermissionAction.View) {
|
||||
return (
|
||||
this.currentUserOwnsObject(object) ||
|
||||
object.permissions?.view.users.includes(this.currentUser.id) ||
|
||||
object.permissions?.view.groups.filter((g) =>
|
||||
this.currentUser.groups.includes(g)
|
||||
).length > 0
|
||||
)
|
||||
} else if (action === PermissionAction.Change) {
|
||||
return (
|
||||
this.currentUserOwnsObject(object) ||
|
||||
object.user_can_change ||
|
||||
object.permissions?.change.users.includes(this.currentUser.id) ||
|
||||
object.permissions?.change.groups.filter((g) =>
|
||||
this.currentUser.groups.includes(g)
|
||||
).length > 0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public getPermissionCode(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue