Merge pull request #2820 from paperless-ngx/fix-2812

Fix: give superuser full doc perms
This commit is contained in:
shamoon 2023-03-10 21:53:35 -08:00 committed by GitHub
commit 2d3cf43bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 13 deletions

View File

@ -1,6 +1,9 @@
{
"user_id": 1,
"username": "admin",
"user": {
"id": 1,
"username": "admin",
"is_superuser": true
},
"settings": {
"language": "",
"bulk_edit": {

View File

@ -1,6 +1,9 @@
{
"user_id": 1,
"username": "admin",
"user": {
"id": 1,
"username": "admin",
"is_superuser": false
},
"settings": {
"language": "",
"bulk_edit": {

View File

@ -1,6 +1,7 @@
import { PaperlessUser } from './paperless-user'
export interface PaperlessUiSettings {
user_id: number
username: string
user: PaperlessUser
settings: Object
permissions: string[]
}

View File

@ -46,7 +46,12 @@ export class PermissionsService {
}
public currentUserOwnsObject(object: ObjectWithPermissions): boolean {
return !object || !object.owner || object.owner === this.currentUser.id
return (
!object ||
!object.owner ||
this.currentUser.is_superuser ||
object.owner === this.currentUser.id
)
}
public currentUserHasObjectPermissions(

View File

@ -75,10 +75,7 @@ export class SettingsService {
// to update lang cookie
if (this.settings['language']?.length)
this.setLanguage(this.settings['language'])
this.currentUser = {
id: uisettings['user_id'],
username: uisettings['username'],
}
this.currentUser = uisettings.user
this.permissionsService.initialize(
uisettings.permissions,
this.currentUser

View File

@ -931,8 +931,11 @@ class UiSettingsView(GenericAPIView):
roles = map(lambda perm: re.sub(r"^\w+.", "", perm), user.get_all_permissions())
return Response(
{
"user_id": user.id,
"username": user.username,
"user": {
"id": user.id,
"username": user.username,
"is_superuser": user.is_superuser,
},
"settings": ui_settings,
"permissions": roles,
},