mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-08 07:45:32 +01:00
Change: restrict altering and creation of superusers to superusers only (#8837)
This commit is contained in:
parent
475c231c6f
commit
41bcc12cc2
7 changed files with 194 additions and 1 deletions
|
|
@ -160,4 +160,23 @@ describe('UserEditDialogComponent', () => {
|
|||
})
|
||||
expect(component.currentUserIsSuperUser).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should disable superuser option if current user is not superuser', () => {
|
||||
const control: AbstractControl = component.objectForm.get('is_superuser')
|
||||
permissionsService.initialize([], {
|
||||
id: 99,
|
||||
username: 'user99',
|
||||
is_superuser: false,
|
||||
})
|
||||
component.ngOnInit()
|
||||
expect(control.disabled).toBeTruthy()
|
||||
|
||||
permissionsService.initialize([], {
|
||||
id: 99,
|
||||
username: 'user99',
|
||||
is_superuser: true,
|
||||
})
|
||||
component.ngOnInit()
|
||||
expect(control.disabled).toBeFalsy()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -60,6 +60,11 @@ export class UserEditDialogComponent
|
|||
ngOnInit(): void {
|
||||
super.ngOnInit()
|
||||
this.onToggleSuperUser()
|
||||
if (!this.currentUserIsSuperUser) {
|
||||
this.objectForm.get('is_superuser').disable()
|
||||
} else {
|
||||
this.objectForm.get('is_superuser').enable()
|
||||
}
|
||||
}
|
||||
|
||||
getCreateTitle() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue