File tree Expand file tree Collapse file tree
commands/createApp/templates
documentation/docs/tutorial Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Add only non-sensitive production environment variables here so deployed applications can use them
22# Deliver sensitive production environment variables via your deployment platform's process environment
33
4- NODE_ENV=production
5- DATABASE_URL={{ dbUrlProd }}
6- {{ #if prismaDbUrlProd }}
7- PRISMA_DATABASE_URL={{ prismaDbUrlProd }}
8- {{ /if }}
4+ NODE_ENV=production
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ docker run -p 3500:3500 \
3737```
3838
3939> ` -v $(pwd)/db:/code/db ` is needed only if you are using SQLite database.
40+ > Pay attention, that ADMINFORTH_SECRET environment should be in deployed app as well
4041
4142Now open your browser and go to ` http://localhost:3500 ` to see your AdminForth application running in Docker container.
4243
Original file line number Diff line number Diff line change @@ -1255,6 +1255,14 @@ export default class ConfigValidator implements IConfigValidator {
12551255 throw new Error ( `Invalid AdminForth config: ${ errors . join ( ', ' ) } ` ) ;
12561256 }
12571257
1258+ const adminforthSecret = process . env . ADMINFORTH_SECRET ;
1259+ if ( ! adminforthSecret ) {
1260+ throw new Error ( `ADMINFORTH_SECRET environment not set
1261+ Please set ADMINFORTH_SECRET environment variable to a random string to secure your admin panel.
1262+ ADMINFORTH_SECRET variable is used to sign JWT tokens
1263+ ` ) ;
1264+ }
1265+
12581266 this . adminforth . config = newConfig as AdminForthConfig ;
12591267 }
12601268
Original file line number Diff line number Diff line change @@ -946,7 +946,8 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
946946 if ( menuItem . label ) {
947947 translateRoutines . push (
948948 ( async ( ) => {
949- menuItem . label = await tr ( menuItem . label , `menu.${ menuItem . itemId } ` ) ;
949+ const rawLabel = typeof menuItem . label === 'function' ? await menuItem . label ( adminUser , this . adminforth ) : menuItem . label ;
950+ menuItem . label = await tr ( rawLabel , `menu.${ menuItem . itemId } ` ) ;
950951 } ) ( )
951952 ) ;
952953 }
Original file line number Diff line number Diff line change @@ -1104,8 +1104,16 @@ export interface AdminForthConfigMenuItem {
11041104
11051105 /**
11061106 * Label for menu item which will be displayed in the admin panel.
1107+ * Can be a static string or a callback which receives the current admin user
1108+ * and returns the label dynamically.
1109+ *
1110+ * Example:
1111+ *
1112+ * ```ts
1113+ * label: (adminUser) => adminUser.dbUser.role === 'superadmin' ? 'Dashboard (CRS)' : 'Dashboard',
1114+ * ```
11071115 */
1108- label ?: string ,
1116+ label ?: string | ( ( user : AdminUser , adminForth : IAdminForth ) => Promise < string > | string ) ,
11091117
11101118 /**
11111119 * Icon for menu item which will be displayed in the admin panel.
You can’t perform that action at this time.
0 commit comments