From f812f2af4d81a8ae83e743ea2a80e4cacbd3cc94 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 13 Apr 2024 17:35:34 -0700 Subject: [PATCH] Fix: remove admin.logentry perm, use admin (staff) status (#6380) --- docs/usage.md | 6 ++- src-ui/src/app/app-routing.module.ts | 5 +-- .../admin/settings/settings.component.html | 43 ++++++++++--------- .../admin/settings/settings.component.spec.ts | 1 + .../admin/settings/settings.component.ts | 9 +--- .../app-frame/app-frame.component.html | 16 ++++--- .../user-edit-dialog.component.html | 6 ++- .../user-edit-dialog.component.ts | 1 + src-ui/src/app/guards/permissions.guard.ts | 10 +++-- .../app/services/permissions.service.spec.ts | 21 +++++++++ .../src/app/services/permissions.service.ts | 5 ++- src/documents/permissions.py | 2 +- src/documents/tests/test_api_permissions.py | 1 + src/documents/tests/test_api_uisettings.py | 1 + src/documents/views.py | 1 + 15 files changed, 81 insertions(+), 47 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index d77b3b2a6..7cedb976a 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -241,6 +241,11 @@ permissions can be granted to limit access to certain parts of the UI (and corre Superusers can access all parts of the front and backend application as well as any and all objects. +#### Admin Status + +Admin status (Django 'staff status') grants access to viewing the paperless logs and the system status dialog +as well as accessing the Django backend. + #### Detailed Explanation of Global Permissions {#global-permissions} Global permissions define what areas of the app and API endpoints the user can access. For example, they @@ -249,7 +254,6 @@ still have "object-level" permissions. | Type | Details | | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Admin | _View_ or higher permissions grants access to the logs view as well as the system status. | | AppConfig | _Change_ or higher permissions grants access to the "Application Configuration" area. | | Correspondent | Grants global permissions to add, edit, delete or view Correspondents. | | CustomField | Grants global permissions to add, edit, delete or view Custom Fields. | diff --git a/src-ui/src/app/app-routing.module.ts b/src-ui/src/app/app-routing.module.ts index 3eebd31bd..12b412f67 100644 --- a/src-ui/src/app/app-routing.module.ts +++ b/src-ui/src/app/app-routing.module.ts @@ -141,10 +141,7 @@ export const routes: Routes = [ component: LogsComponent, canActivate: [PermissionsGuard], data: { - requiredPermission: { - action: PermissionAction.View, - type: PermissionType.Admin, - }, + requireAdmin: true, }, }, // redirect old paths diff --git a/src-ui/src/app/components/admin/settings/settings.component.html b/src-ui/src/app/components/admin/settings/settings.component.html index 42147a9b8..0fc744edb 100644 --- a/src-ui/src/app/components/admin/settings/settings.component.html +++ b/src-ui/src/app/components/admin/settings/settings.component.html @@ -7,29 +7,30 @@ - - - Open Django Admin -   - + System Status + + + Open Django Admin +   + + }
diff --git a/src-ui/src/app/components/admin/settings/settings.component.spec.ts b/src-ui/src/app/components/admin/settings/settings.component.spec.ts index 6110f7d1d..d53f57b69 100644 --- a/src-ui/src/app/components/admin/settings/settings.component.spec.ts +++ b/src-ui/src/app/components/admin/settings/settings.component.spec.ts @@ -418,6 +418,7 @@ describe('SettingsComponent', () => { }, } jest.spyOn(systemStatusService, 'get').mockReturnValue(of(status)) + jest.spyOn(permissionsService, 'isAdmin').mockReturnValue(true) completeSetup() expect(component['systemStatus']).toEqual(status) // private expect(component.systemStatusHasErrors).toBeTruthy() diff --git a/src-ui/src/app/components/admin/settings/settings.component.ts b/src-ui/src/app/components/admin/settings/settings.component.ts index f04af2f9d..33f6949a1 100644 --- a/src-ui/src/app/components/admin/settings/settings.component.ts +++ b/src-ui/src/app/components/admin/settings/settings.component.ts @@ -121,7 +121,7 @@ export class SettingsComponent users: User[] groups: Group[] - private systemStatus: SystemStatus + public systemStatus: SystemStatus get systemStatusHasErrors(): boolean { return ( @@ -385,12 +385,7 @@ export class SettingsComponent this.settingsForm.patchValue(currentFormValue) } - if ( - this.permissionsService.currentUserCan( - PermissionAction.View, - PermissionType.Admin - ) - ) { + if (this.permissionsService.isAdmin()) { this.systemStatusService.get().subscribe((status) => { this.systemStatus = status }) diff --git a/src-ui/src/app/components/app-frame/app-frame.component.html b/src-ui/src/app/components/app-frame/app-frame.component.html index b79f99cc0..bdc8d08f2 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.html +++ b/src-ui/src/app/components/app-frame/app-frame.component.html @@ -267,13 +267,15 @@ } - + @if (permissionsService.isAdmin()) { + + }