From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 14 Apr 2024 00:35:34 +0000 (-0700) Subject: Fix: remove admin.logentry perm, use admin (staff) status (#6380) X-Git-Tag: v2.8.0~3^2~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f812f2af4d81a8ae83e743ea2a80e4cacbd3cc94;p=thirdparty%2Fpaperless-ngx.git Fix: remove admin.logentry perm, use admin (staff) status (#6380) --- diff --git a/docs/usage.md b/docs/usage.md index d77b3b2a6f..7cedb976a9 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 3eebd31bd2..12b412f67b 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 42147a9b83..0fc744edb5 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 6110f7d1d8..d53f57b698 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 f04af2f9db..33f6949a14 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 b79f99cc04..bdc8d08f25 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()) { + + }