Give superuser full doc permissions

This commit is contained in:
shamoon 2023-03-03 19:50:06 -08:00
parent 2fe7f8be46
commit 320537a054
6 changed files with 25 additions and 13 deletions

View File

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

View File

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

View File

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

View File

@ -46,7 +46,12 @@ export class PermissionsService {
} }
public currentUserOwnsObject(object: ObjectWithPermissions): boolean { 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( public currentUserHasObjectPermissions(

View File

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

View File

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