Skip to content

Commit 99dfa59

Browse files
authored
Merge pull request #647 from devforth/next
Next
2 parents 526cf72 + acca2aa commit 99dfa59

5 files changed

Lines changed: 21 additions & 7 deletions

File tree

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
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

adminforth/documentation/docs/tutorial/04-deploy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
4142
Now open your browser and go to `http://localhost:3500` to see your AdminForth application running in Docker container.
4243

adminforth/modules/configValidator.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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

adminforth/modules/restApi.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

adminforth/types/Common.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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.

0 commit comments

Comments
 (0)