Skip to content

Commit 4a57bc9

Browse files
committed
fix: rename canModifyUsers to allowedForSuperAdmin for clarity and restrict actions to superadmin only
1 parent b3f13f7 commit 4a57bc9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

adminforth/commands/createApp/templates/adminuser.ts.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import AdminForth, { AdminForthDataTypes } from 'adminforth';
22
import type { AdminForthResourceInput, AdminForthResource, AdminUser } from 'adminforth';
33
import { randomUUID } from 'crypto';
44

5-
async function canModifyUsers({ adminUser }: { adminUser: AdminUser }): Promise<boolean> {
5+
async function allowedForSuperAdmin({ adminUser }: { adminUser: AdminUser }): Promise<boolean> {
66
return adminUser.dbUser.role === 'superadmin';
77
}
88

@@ -14,8 +14,8 @@ export default {
1414
recordLabel: (r) => `👤 ${r.email}`,
1515
options: {
1616
allowedActions: {
17-
edit: canModifyUsers,
18-
delete: canModifyUsers,
17+
edit: allowedForSuperAdmin,
18+
delete: allowedForSuperAdmin,
1919
},
2020
},
2121
columns: [

adminforth/documentation/docs/tutorial/03-Customization/05-limitingAccess.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Let's disable creating and editing of new users for all users apart from users w
106106
import type { AdminUser } from 'adminforth';
107107

108108
//diff-add
109-
async function canModifyUsers({ adminUser }: { adminUser: AdminUser }): Promise<boolean> {
109+
async function allowedForSuperAdmin({ adminUser }: { adminUser: AdminUser }): Promise<boolean> {
110110
//diff-add
111111
return adminUser.dbUser.role === 'superadmin';
112112
//diff-add
@@ -121,9 +121,9 @@ async function canModifyUsers({ adminUser }: { adminUser: AdminUser }): Promise<
121121
options: {
122122
allowedActions: {
123123
//diff-add
124-
create: canModifyUsers,
124+
create: allowedForSuperAdmin,
125125
//diff-add
126-
edit: canModifyUsers,
126+
edit: allowedForSuperAdmin,
127127
delete: false
128128
}
129129
...

0 commit comments

Comments
 (0)