mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Merge pull request #2820 from paperless-ngx/fix-2812
Fix: give superuser full doc perms
This commit is contained in:
commit
2d3cf43bc5
@ -1,6 +1,9 @@
|
||||
{
|
||||
"user_id": 1,
|
||||
"user": {
|
||||
"id": 1,
|
||||
"username": "admin",
|
||||
"is_superuser": true
|
||||
},
|
||||
"settings": {
|
||||
"language": "",
|
||||
"bulk_edit": {
|
||||
|
@ -1,6 +1,9 @@
|
||||
{
|
||||
"user_id": 1,
|
||||
"user": {
|
||||
"id": 1,
|
||||
"username": "admin",
|
||||
"is_superuser": false
|
||||
},
|
||||
"settings": {
|
||||
"language": "",
|
||||
"bulk_edit": {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { PaperlessUser } from './paperless-user'
|
||||
|
||||
export interface PaperlessUiSettings {
|
||||
user_id: number
|
||||
username: string
|
||||
user: PaperlessUser
|
||||
settings: Object
|
||||
permissions: string[]
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
"user": {
|
||||
"id": user.id,
|
||||
"username": user.username,
|
||||
"is_superuser": user.is_superuser,
|
||||
},
|
||||
"settings": ui_settings,
|
||||
"permissions": roles,
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user