mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Give superuser full doc permissions
This commit is contained in:
parent
2fe7f8be46
commit
320537a054
@ -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": {
|
||||||
|
@ -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": {
|
||||||
|
@ -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[]
|
||||||
}
|
}
|
||||||
|
@ -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(
|
||||||
|
@ -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
|
||||||
|
@ -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,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user