forked from ToolJet/ToolJet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix role change when only one admin is present (ToolJet#766)
- Loading branch information
1 parent
eb73c9c
commit 4000514
Showing
3 changed files
with
93 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,6 +174,23 @@ describe('organization users controller', () => { | |
expect(developerUserData.orgUser.role).toBe('developer'); | ||
}); | ||
|
||
it('should not allow to change role from admin when no other admins are present', async () => { | ||
const adminUserData = await createUser(app, { | ||
email: '[email protected]', | ||
role: 'admin', | ||
status: 'active', | ||
}); | ||
|
||
const response = await request(app.getHttpServer()) | ||
.post(`/organization_users/${adminUserData.orgUser.id}/change_role`) | ||
.set('Authorization', authHeaderForUser(adminUserData.user)) | ||
.send({ role: 'viewer' }) | ||
.expect(400); | ||
|
||
await adminUserData.orgUser.reload(); | ||
expect(adminUserData.orgUser.role).toBe('admin'); | ||
}); | ||
|
||
it('should allow only admin users to archive org users', async () => { | ||
const adminUserData = await createUser(app, { | ||
email: '[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters