adminizer 4.1.0-build.11 → 4.1.0-build.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/controllers/add.js +2 -2
- package/controllers/addGroup.js +2 -2
- package/controllers/addUser.js +2 -2
- package/controllers/catalog/Catalog.js +2 -2
- package/controllers/catalog/FrontentCatalogAdapter.js +1 -1
- package/controllers/ckeditorUpload.js +2 -2
- package/controllers/dashboard.js +1 -1
- package/controllers/edit.js +2 -2
- package/controllers/editGroup.js +2 -2
- package/controllers/editUser.js +2 -2
- package/controllers/form.js +2 -2
- package/controllers/getAllWidgets.js +3 -3
- package/controllers/list.js +2 -2
- package/controllers/login.js +20 -9
- package/controllers/media-manager/mediaManagerApi.js +2 -2
- package/controllers/navigation/edit.js +1 -1
- package/controllers/processInstallFinalize.js +2 -2
- package/controllers/processInstallStep.d.ts +0 -1
- package/controllers/processInstallStep.js +122 -132
- package/controllers/remove.js +2 -2
- package/controllers/timezones.js +1 -1
- package/controllers/view.js +2 -2
- package/controllers/welcome.js +1 -1
- package/controllers/widgets/Action.js +2 -2
- package/controllers/widgets/Custom.js +2 -2
- package/controllers/widgets/Info.js +2 -2
- package/controllers/widgets/switch.js +2 -2
- package/controllers/widgetsDB.js +3 -3
- package/helpers/accessRightsHelper.d.ts +3 -2
- package/helpers/accessRightsHelper.js +1 -1
- package/helpers/inertiaActionsHelper.js +1 -1
- package/helpers/inertiaAddHelper.d.ts +1 -1
- package/helpers/inertiaGroupHelper.d.ts +4 -2
- package/helpers/inertiaGroupHelper.js +1 -1
- package/helpers/inertiaListHelper.js +5 -5
- package/helpers/inertiaMenuHelper.js +1 -1
- package/helpers/inertiaUserHelper.d.ts +3 -1
- package/helpers/inertiaUserHelper.js +1 -1
- package/interfaces/adminpanelConfig.d.ts +4 -2
- package/interfaces/global.d.ts +5 -26
- package/lib/Adminizer.d.ts +1 -0
- package/lib/Adminizer.js +3 -1
- package/lib/catalog/Navigation.js +6 -6
- package/lib/installStepper/installStepper.js +5 -5
- package/lib/v4/DataAccessor.d.ts +2 -1
- package/lib/v4/DataAccessor.js +1 -1
- package/lib/v4/helper/jwt.d.ts +10 -0
- package/lib/v4/helper/jwt.js +18 -0
- package/lib/widgets/widgetHandler.d.ts +2 -1
- package/models/GroupAP.d.ts +1 -1
- package/models/UserAP.d.ts +6 -4
- package/models/UserAP.js +2 -2
- package/package.json +8 -5
- package/policies/checkAuth.js +4 -3
- package/policies/setLocale.js +2 -2
- package/system/Router.js +8 -8
- package/system/bindAuthorization.js +1 -2
- package/system/bindInertia.js +8 -8
- package/system/bindInstallStepper.js +1 -1
- package/system/bindReqFunctions.js +16 -0
|
@@ -4,10 +4,10 @@ export async function widgetInfoController(req, res) {
|
|
|
4
4
|
return res.status(404).send({ error: 'Not Found' });
|
|
5
5
|
}
|
|
6
6
|
if (req.adminizer.config.auth.enable) {
|
|
7
|
-
if (!req.
|
|
7
|
+
if (!req.user) {
|
|
8
8
|
return res.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
9
9
|
}
|
|
10
|
-
else if (!req.adminizer.accessRightsHelper.hasPermission(`widget-${widgetId}`, req.
|
|
10
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`widget-${widgetId}`, req.user)) {
|
|
11
11
|
return res.sendStatus(403);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -4,10 +4,10 @@ export async function widgetSwitchController(req, res) {
|
|
|
4
4
|
return res.status(404).send({ error: 'Not Found' });
|
|
5
5
|
}
|
|
6
6
|
if (req.adminizer.config.auth.enable) {
|
|
7
|
-
if (!req.
|
|
7
|
+
if (!req.user) {
|
|
8
8
|
return res.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
9
9
|
}
|
|
10
|
-
else if (!req.adminizer.accessRightsHelper.hasPermission(`widget-${widgetId}`, req.
|
|
10
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`widget-${widgetId}`, req.user)) {
|
|
11
11
|
return res.sendStatus(403);
|
|
12
12
|
}
|
|
13
13
|
}
|
package/controllers/widgetsDB.js
CHANGED
|
@@ -2,13 +2,13 @@ export default async function widgetsDB(req, res) {
|
|
|
2
2
|
let id = 0;
|
|
3
3
|
let auth = req.adminizer.config.auth.enable;
|
|
4
4
|
if (auth) {
|
|
5
|
-
if (!req.
|
|
5
|
+
if (!req.user) {
|
|
6
6
|
return res.redirect(`${req.adminizer.config.routePrefix}/model/userap/login`);
|
|
7
7
|
}
|
|
8
|
-
else if (!req.adminizer.accessRightsHelper.hasPermission(`widgets`, req.
|
|
8
|
+
else if (!req.adminizer.accessRightsHelper.hasPermission(`widgets`, req.user)) {
|
|
9
9
|
return res.sendStatus(403);
|
|
10
10
|
}
|
|
11
|
-
id = req.
|
|
11
|
+
id = req.user.id;
|
|
12
12
|
}
|
|
13
13
|
if (req.method.toUpperCase() === 'GET') {
|
|
14
14
|
try {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UserAP } from "models/UserAP";
|
|
1
2
|
import { AccessRightsToken } from "../interfaces/types";
|
|
2
3
|
import { Adminizer } from "../lib/Adminizer";
|
|
3
4
|
export declare class AccessRightsHelper {
|
|
@@ -9,6 +10,6 @@ export declare class AccessRightsHelper {
|
|
|
9
10
|
getTokens(): AccessRightsToken[];
|
|
10
11
|
getTokensByDepartment(department: string): AccessRightsToken[];
|
|
11
12
|
getAllDepartments(): string[];
|
|
12
|
-
enoughPermissions(tokens: string[], user:
|
|
13
|
-
hasPermission(tokenId: string, user:
|
|
13
|
+
enoughPermissions(tokens: string[], user: UserAP): boolean;
|
|
14
|
+
hasPermission(tokenId: string, user: UserAP): boolean;
|
|
14
15
|
}
|
|
@@ -53,6 +53,6 @@ export class AccessRightsHelper {
|
|
|
53
53
|
Adminizer.log.error("Adminpanel > Token is not valid");
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
|
-
return user.groups.some((group) => group.tokens
|
|
56
|
+
return user.groups.some((group) => group.tokens?.includes(tokenId));
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -4,7 +4,7 @@ export default function inertiaActionsHelper(actionType, entity, req) {
|
|
|
4
4
|
const actions = req.adminizer.menuHelper.getGlobalActions(entity.config, actionType);
|
|
5
5
|
if (actions && actions.length > 0) {
|
|
6
6
|
actions.forEach(function (action) {
|
|
7
|
-
if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.
|
|
7
|
+
if (req.adminizer.accessRightsHelper.hasPermission(action.accessRightsToken, req.user)) {
|
|
8
8
|
resActions.push({
|
|
9
9
|
link: action.link,
|
|
10
10
|
id: action.id,
|
|
@@ -436,7 +436,7 @@ export declare function getControlsOptions(fieldConfig: BaseFieldConfig, req: Re
|
|
|
436
436
|
};
|
|
437
437
|
path: {};
|
|
438
438
|
};
|
|
439
|
-
export declare function inputText(type: string, isIn: string[]): "email" | "password" | "
|
|
439
|
+
export declare function inputText(type: string, isIn: string[]): "email" | "password" | "date" | "time" | "number" | "color" | "month" | "week" | "range" | "text" | "select" | "datetime-local";
|
|
440
440
|
export declare function getControl(req: ReqType, type: ControlType, name: string | undefined, defaultControlName: string): AbstractControls;
|
|
441
441
|
export declare function setSelectMany(isIn: string[], value: string[] | undefined): {
|
|
442
442
|
initOptions: {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GroupAP } from "models/GroupAP";
|
|
2
|
+
import { UserAP } from "models/UserAP";
|
|
1
3
|
import { AccessRightsToken, Entity, PropsField } from "../interfaces/types";
|
|
2
4
|
interface groupedTokens {
|
|
3
5
|
header: string;
|
|
@@ -20,7 +22,7 @@ interface listProps extends Record<string | number | symbol, unknown> {
|
|
|
20
22
|
users: PropsField[];
|
|
21
23
|
groupedTokens: groupedTokens[];
|
|
22
24
|
}
|
|
23
|
-
export declare function inertiaGroupHelper(entity: Entity, req: ReqType, users:
|
|
25
|
+
export declare function inertiaGroupHelper(entity: Entity, req: ReqType, users: UserAP[], groupedTokens: {
|
|
24
26
|
[key: string]: AccessRightsToken[];
|
|
25
|
-
}, group?:
|
|
27
|
+
}, group?: GroupAP, view?: boolean): listProps;
|
|
26
28
|
export {};
|
|
@@ -55,7 +55,7 @@ export function inertiaGroupHelper(entity, req, users, groupedTokens, group, vie
|
|
|
55
55
|
label: token.name,
|
|
56
56
|
tooltip: token.description,
|
|
57
57
|
name: `token-checkbox-${token.id}`,
|
|
58
|
-
value: group ? (group.tokens && group.tokens
|
|
58
|
+
value: group ? (group.tokens && group.tokens?.includes(token.id)) : false,
|
|
59
59
|
type: 'checkbox'
|
|
60
60
|
});
|
|
61
61
|
}
|
|
@@ -24,22 +24,22 @@ export function inertiaListHelper(entity, req, fields) {
|
|
|
24
24
|
searchBtn: req.i18n.__('Search'),
|
|
25
25
|
resetBtn: req.i18n.__('Reset'),
|
|
26
26
|
};
|
|
27
|
-
if (entity.config.add && req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.
|
|
27
|
+
if (entity.config.add && req.adminizer.accessRightsHelper.hasPermission(`create-${entity.name}-model`, req.user)) {
|
|
28
28
|
props.crudActions.createTitle = req.i18n.__('create');
|
|
29
29
|
}
|
|
30
|
-
if (req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.
|
|
30
|
+
if (req.adminizer.accessRightsHelper.hasPermission(`update-${entity.name}-model`, req.user)) {
|
|
31
31
|
props.crudActions.editTitle = req.i18n.__('Edit');
|
|
32
32
|
}
|
|
33
|
-
if (req.adminizer.accessRightsHelper.hasPermission(`read-${entity.name}-model`, req.
|
|
33
|
+
if (req.adminizer.accessRightsHelper.hasPermission(`read-${entity.name}-model`, req.user)) {
|
|
34
34
|
props.crudActions.viewsTitle = req.i18n.__('View');
|
|
35
35
|
}
|
|
36
|
-
if (req.adminizer.accessRightsHelper.hasPermission(`delete-${entity.name}-model`, req.
|
|
36
|
+
if (req.adminizer.accessRightsHelper.hasPermission(`delete-${entity.name}-model`, req.user)) {
|
|
37
37
|
props.crudActions.deleteTitle = req.i18n.__('Delete');
|
|
38
38
|
}
|
|
39
39
|
props.actions = inertiaActionsHelper(actionType, entity, req);
|
|
40
40
|
if (req.adminizer.menuHelper.hasInlineActions(entity.config, 'list')) {
|
|
41
41
|
for (const inlineAction of req.adminizer.menuHelper.getInlineActions(entity.config, 'list')) {
|
|
42
|
-
if (req.adminizer.accessRightsHelper.hasPermission(inlineAction.accessRightsToken, req.
|
|
42
|
+
if (req.adminizer.accessRightsHelper.hasPermission(inlineAction.accessRightsToken, req.user)) {
|
|
43
43
|
props.inlineActions.push({
|
|
44
44
|
icon: inlineAction.icon,
|
|
45
45
|
id: inlineAction.id,
|
|
@@ -13,7 +13,7 @@ export class InertiaMenuHelper {
|
|
|
13
13
|
}) : [];
|
|
14
14
|
if (menuItem.accessRightsToken)
|
|
15
15
|
menuItemTokens.push(menuItem.accessRightsToken);
|
|
16
|
-
if (this.adminizer.accessRightsHelper.enoughPermissions(menuItemTokens, req.
|
|
16
|
+
if (this.adminizer.accessRightsHelper.enoughPermissions(menuItemTokens, req.user)) {
|
|
17
17
|
menu.push(menuItem);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GroupAP } from "models/GroupAP";
|
|
2
|
+
import { UserAP } from "models/UserAP";
|
|
1
3
|
import { Entity, PropsField } from "../interfaces/types";
|
|
2
4
|
interface listProps extends Record<string | number | symbol, unknown> {
|
|
3
5
|
edit: boolean;
|
|
@@ -21,5 +23,5 @@ interface listProps extends Record<string | number | symbol, unknown> {
|
|
|
21
23
|
postLink: string;
|
|
22
24
|
};
|
|
23
25
|
}
|
|
24
|
-
export declare function inertiaUserHelper(entity: Entity, req: ReqType, groups:
|
|
26
|
+
export declare function inertiaUserHelper(entity: Entity, req: ReqType, groups: GroupAP[], user?: UserAP, view?: boolean): listProps;
|
|
25
27
|
export {};
|
|
@@ -62,7 +62,7 @@ export function inertiaUserHelper(entity, req, groups, user, view = false) {
|
|
|
62
62
|
value: user?.locale ?? ''
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
if (req.
|
|
65
|
+
if (req.user.isAdministrator) {
|
|
66
66
|
props.fields.push({
|
|
67
67
|
label: req.i18n.__('Profile expires'),
|
|
68
68
|
type: 'date',
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { MaterialIcon } from "./MaaterialIcons";
|
|
2
2
|
import { EditorOptions } from "@toast-ui/editor/types/editor";
|
|
3
3
|
import { GridSettings as HandsontableSettings } from "handsontable/settings";
|
|
4
|
+
import { GroupAP } from "models/GroupAP";
|
|
5
|
+
import { UserAP } from "models/UserAP";
|
|
4
6
|
export type AdminpanelIcon = MaterialIcon;
|
|
5
7
|
export type FieldsTypes = "string" | "password" | "date" | "datetime" | "time" | "integer" | "number" | "float" | "color" | "email" | "month" | "week" | "range" | "boolean" | "binary" | "text" | "longtext" | "mediumtext" | "ckeditor" | "wysiwyg" | "texteditor" | "word" | 'tui' | 'tuieditor' | 'toast-ui' | "jsoneditor" | "json" | "array" | "object" | "ace" | "code" | "html" | "xml" | "aceeditor" | "menu" | "schedule" | "worktime" | "association" | "association-many" | "select" | "select-many" | "table" | "geojson" | "mediamanager" |
|
|
6
8
|
/**
|
|
@@ -268,8 +270,8 @@ export interface ModelConfig {
|
|
|
268
270
|
} | string;
|
|
269
271
|
userAccessRelationCallback?: (userWithGroups: UserWithGroups, record: any) => boolean;
|
|
270
272
|
}
|
|
271
|
-
type UserWithGroups =
|
|
272
|
-
groups:
|
|
273
|
+
type UserWithGroups = UserAP & {
|
|
274
|
+
groups: GroupAP[];
|
|
273
275
|
};
|
|
274
276
|
export interface FieldsForms {
|
|
275
277
|
[key: string]: FormFieldConfig;
|
package/interfaces/global.d.ts
CHANGED
|
@@ -4,15 +4,10 @@ import multer from "multer";
|
|
|
4
4
|
import { I18n } from "../lib/v4/I18n";
|
|
5
5
|
import { Inertia } from "../lib/inertia/inertiaAdapter";
|
|
6
6
|
import { Flash } from "../lib/inertia/flash";
|
|
7
|
+
import { UserAP } from "models/UserAP";
|
|
7
8
|
declare global {
|
|
9
|
+
/** @deprecated use import from TS model decalration */
|
|
8
10
|
type ModelsAP = {
|
|
9
|
-
GroupAP: {
|
|
10
|
-
id?: number;
|
|
11
|
-
name: string;
|
|
12
|
-
description?: string;
|
|
13
|
-
tokens?: string[];
|
|
14
|
-
users?: ModelsAP["UserAP"][];
|
|
15
|
-
};
|
|
16
11
|
MediaManagerAP: {
|
|
17
12
|
id?: string;
|
|
18
13
|
parent?: ModelsAP["MediaManagerAP"];
|
|
@@ -48,36 +43,20 @@ declare global {
|
|
|
48
43
|
label: string;
|
|
49
44
|
tree: any;
|
|
50
45
|
};
|
|
51
|
-
UserAP: {
|
|
52
|
-
id?: number;
|
|
53
|
-
login?: string;
|
|
54
|
-
fullName?: string;
|
|
55
|
-
email?: string;
|
|
56
|
-
passwordHashed?: string;
|
|
57
|
-
password?: string;
|
|
58
|
-
timezone?: string;
|
|
59
|
-
expires?: string;
|
|
60
|
-
locale?: string;
|
|
61
|
-
isDeleted?: boolean;
|
|
62
|
-
isActive?: boolean;
|
|
63
|
-
isAdministrator?: boolean;
|
|
64
|
-
groups?: ModelsAP["GroupAP"][];
|
|
65
|
-
widgets?: any;
|
|
66
|
-
isConfirmed?: boolean;
|
|
67
|
-
};
|
|
68
46
|
};
|
|
69
47
|
type reqSession = {
|
|
70
48
|
flashMessages: Record<string, string[]>;
|
|
71
49
|
xInertiaCurrentComponent: string | undefined;
|
|
72
|
-
UserAP:
|
|
50
|
+
UserAP: UserAP;
|
|
73
51
|
messages: {
|
|
74
52
|
adminError: string[];
|
|
75
53
|
adminSuccess: string[];
|
|
76
54
|
};
|
|
77
|
-
|
|
55
|
+
userPretended?: UserAP;
|
|
78
56
|
};
|
|
79
57
|
type FlashMessages = 'info' | 'error' | 'success' | string;
|
|
80
58
|
type ReqType = Request & {
|
|
59
|
+
user: UserAP;
|
|
81
60
|
Inertia: Inertia;
|
|
82
61
|
flash: Flash<FlashMessages>;
|
|
83
62
|
session: reqSession;
|
package/lib/Adminizer.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare class Adminizer {
|
|
|
24
24
|
widgetHandler: WidgetHandler;
|
|
25
25
|
vite: ViteDevServer;
|
|
26
26
|
controlsHandler: ControlsHandler;
|
|
27
|
+
jwtSecret: string;
|
|
27
28
|
static logger: winston.Logger;
|
|
28
29
|
constructor(ormAdapters: AbstractAdapter[]);
|
|
29
30
|
getMiddleware(): (req: any, res: any) => void;
|
package/lib/Adminizer.js
CHANGED
|
@@ -29,6 +29,7 @@ import { bindInertia } from "../system/bindInertia";
|
|
|
29
29
|
import { MenuHelper } from "../helpers/menuHelper";
|
|
30
30
|
import { bindControls } from "../system/bindControls";
|
|
31
31
|
import { ControlsHandler } from "./controls/ControlsHandler";
|
|
32
|
+
import { v4 as uuid } from "uuid";
|
|
32
33
|
export class Adminizer {
|
|
33
34
|
app;
|
|
34
35
|
config;
|
|
@@ -42,6 +43,7 @@ export class Adminizer {
|
|
|
42
43
|
widgetHandler;
|
|
43
44
|
vite;
|
|
44
45
|
controlsHandler;
|
|
46
|
+
jwtSecret = process.env.JWT_SECRET ?? uuid();
|
|
45
47
|
static logger = winston.createLogger({
|
|
46
48
|
level: "info",
|
|
47
49
|
format: winston.format.combine(winston.format.timestamp(), winston.format.printf(({ timestamp, level, message, ...meta }) => {
|
|
@@ -62,7 +64,7 @@ export class Adminizer {
|
|
|
62
64
|
return (req, res) => {
|
|
63
65
|
this.app(req, res, (err) => {
|
|
64
66
|
if (err) {
|
|
65
|
-
console.
|
|
67
|
+
console.error("Error in Adminizer", err);
|
|
66
68
|
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
67
69
|
res.end('Internal Server Error');
|
|
68
70
|
}
|
|
@@ -326,7 +326,7 @@
|
|
|
326
326
|
// let items = await this.adminizer.modelHandler.model.get(this.model)["_find"]({})
|
|
327
327
|
//
|
|
328
328
|
// // This dirty hack is here because the field of view is disappearing
|
|
329
|
-
// req.i18n.setLocale(req.
|
|
329
|
+
// req.i18n.setLocale(req.user.locale);
|
|
330
330
|
// const __ = (s: string) => {
|
|
331
331
|
// return req.i18n.__(s)
|
|
332
332
|
// }
|
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
// let type: 'html' = 'html'
|
|
355
355
|
//
|
|
356
356
|
// // This dirty hack is here because the field of view is disappearing
|
|
357
|
-
// req.i18n.setLocale(req.
|
|
357
|
+
// req.i18n.setLocale(req.user.locale);
|
|
358
358
|
// const __ = (s: string) => {
|
|
359
359
|
// return req.i18n.__(s)
|
|
360
360
|
// }
|
|
@@ -433,7 +433,7 @@
|
|
|
433
433
|
// let type: 'html' = 'html'
|
|
434
434
|
//
|
|
435
435
|
// // This dirty hack is here because the field of view is disappearing
|
|
436
|
-
// req.i18n.setLocale(req.
|
|
436
|
+
// req.i18n.setLocale(req.user.locale);
|
|
437
437
|
// const __ = (s: string) => {
|
|
438
438
|
// return req.i18n.__(s)
|
|
439
439
|
// }
|
|
@@ -460,7 +460,7 @@
|
|
|
460
460
|
// let item = await this.find(id, catalogId)
|
|
461
461
|
//
|
|
462
462
|
// // This dirty hack is here because the field of view is disappearing
|
|
463
|
-
// req.i18n.setLocale(req.
|
|
463
|
+
// req.i18n.setLocale(req.user.locale);
|
|
464
464
|
// const __ = (s: string) => {
|
|
465
465
|
// return req.i18n.__(s)
|
|
466
466
|
// }
|
|
@@ -496,7 +496,7 @@
|
|
|
496
496
|
//
|
|
497
497
|
// getAddHTML(req: ReqType): Promise<{ type: "link" | "html" | "jsonForm"; data: string }> {
|
|
498
498
|
// let type: 'html' = 'html'
|
|
499
|
-
// req.i18n.setLocale(req.
|
|
499
|
+
// req.i18n.setLocale(req.user.locale);
|
|
500
500
|
//
|
|
501
501
|
// const __ = (s: string) => {
|
|
502
502
|
// return req.i18n.__(s)
|
|
@@ -514,7 +514,7 @@
|
|
|
514
514
|
// let type: 'html' = 'html'
|
|
515
515
|
// let item = await this.find(id, catalogId)
|
|
516
516
|
//
|
|
517
|
-
// req.i18n.setLocale(req.
|
|
517
|
+
// req.i18n.setLocale(req.user.locale);
|
|
518
518
|
// const __ = (s: string) => {
|
|
519
519
|
// return req.i18n.__(s)
|
|
520
520
|
// }
|
|
@@ -91,21 +91,21 @@ export class InstallStepper {
|
|
|
91
91
|
let leftSteps = this.steps.filter(step => !step.isProcessed && !step.isSkipped);
|
|
92
92
|
// set locale
|
|
93
93
|
if (typeof req.adminizer.config.translation !== "boolean") {
|
|
94
|
-
if (!req.
|
|
95
|
-
req.
|
|
94
|
+
if (!req.user.locale || !req.adminizer.config.translation.locales.includes(req.user.locale)) {
|
|
95
|
+
req.user.locale = req.adminizer.config.translation.defaultLocale || "en";
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
|
-
req.
|
|
99
|
+
req.user.locale = "en";
|
|
100
100
|
}
|
|
101
|
-
this.context.locale = req.
|
|
101
|
+
this.context.locale = req.user.locale;
|
|
102
102
|
// translate step
|
|
103
103
|
stepToRender = TranslationHelper.translateProperties(req.i18n, stepToRender, ["title", "description", "name"]);
|
|
104
104
|
return {
|
|
105
105
|
totalStepCount: this.steps.length,
|
|
106
106
|
leftStepsCount: leftSteps.length,
|
|
107
107
|
currentStep: stepToRender,
|
|
108
|
-
locale: req.
|
|
108
|
+
locale: req.user.locale
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
async skipStep(stepId) {
|
package/lib/v4/DataAccessor.d.ts
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
import { Entity } from "../../interfaces/types";
|
|
5
5
|
import { ActionType } from "../../interfaces/adminpanelConfig";
|
|
6
6
|
import { Fields } from "../../helpers/fieldsHelper";
|
|
7
|
+
import { UserAP } from "models/UserAP";
|
|
7
8
|
export declare class DataAccessor {
|
|
8
9
|
private readonly adminizer;
|
|
9
|
-
user:
|
|
10
|
+
user: UserAP;
|
|
10
11
|
entity: Entity;
|
|
11
12
|
action: ActionType;
|
|
12
13
|
private fields;
|
package/lib/v4/DataAccessor.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function signUser(user: JwtPayload, JWT_SECRET: string): string;
|
|
2
|
+
interface JwtPayload {
|
|
3
|
+
id: number;
|
|
4
|
+
login: string;
|
|
5
|
+
isAdministrator?: boolean;
|
|
6
|
+
iat?: number;
|
|
7
|
+
exp?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function verifyUser(token: string, JWT_SECRET: string): JwtPayload | null;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import jwt from 'jsonwebtoken';
|
|
2
|
+
export function signUser(user, JWT_SECRET) {
|
|
3
|
+
return jwt.sign(user, JWT_SECRET, {
|
|
4
|
+
expiresIn: '15d',
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
export function verifyUser(token, JWT_SECRET) {
|
|
8
|
+
try {
|
|
9
|
+
const decoded = jwt.verify(token, JWT_SECRET);
|
|
10
|
+
if (typeof decoded === 'object' && decoded !== null && 'id' in decoded && 'login' in decoded) {
|
|
11
|
+
return decoded;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -5,6 +5,7 @@ import LinkBase from "./abstractLink";
|
|
|
5
5
|
import CustomBase from "./abstractCustom";
|
|
6
6
|
import { AdminpanelIcon } from "../../interfaces/adminpanelConfig";
|
|
7
7
|
import { Adminizer } from "../Adminizer";
|
|
8
|
+
import { UserAP } from "models/UserAP";
|
|
8
9
|
export type WidgetType = (SwitcherBase | InfoBase | ActionBase | LinkBase | CustomBase);
|
|
9
10
|
export interface WidgetConfig {
|
|
10
11
|
id: string;
|
|
@@ -32,7 +33,7 @@ export declare class WidgetHandler {
|
|
|
32
33
|
add(widget: WidgetType): void;
|
|
33
34
|
getById(id: string): WidgetType | undefined;
|
|
34
35
|
removeById(id: string): void;
|
|
35
|
-
getAll(user:
|
|
36
|
+
getAll(user: UserAP): Promise<WidgetConfig[]>;
|
|
36
37
|
getWidgetsDB(id: number, auth: boolean): Promise<WidgetConfig[]>;
|
|
37
38
|
setWidgetsDB(id: number, widgets: WidgetConfig[], auth: boolean): Promise<number>;
|
|
38
39
|
}
|
package/models/GroupAP.d.ts
CHANGED
package/models/UserAP.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WidgetConfig } from "lib/widgets/widgetHandler";
|
|
1
2
|
import { GroupAP } from "./GroupAP";
|
|
2
3
|
declare const _default: {
|
|
3
4
|
id: {
|
|
@@ -17,10 +18,10 @@ declare const _default: {
|
|
|
17
18
|
email: {
|
|
18
19
|
type: string;
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
+
avatar: {
|
|
21
22
|
type: string;
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
+
passwordHashed: {
|
|
24
25
|
type: string;
|
|
25
26
|
};
|
|
26
27
|
timezone: {
|
|
@@ -56,8 +57,9 @@ export default _default;
|
|
|
56
57
|
export interface UserAP {
|
|
57
58
|
id: number;
|
|
58
59
|
login: string;
|
|
59
|
-
fullName
|
|
60
|
+
fullName?: string;
|
|
60
61
|
email?: string;
|
|
62
|
+
avatar?: string;
|
|
61
63
|
passwordHashed?: string;
|
|
62
64
|
timezone?: string;
|
|
63
65
|
expires?: string;
|
|
@@ -66,6 +68,6 @@ export interface UserAP {
|
|
|
66
68
|
isActive?: boolean;
|
|
67
69
|
isAdministrator?: boolean;
|
|
68
70
|
groups?: GroupAP[];
|
|
69
|
-
widgets?:
|
|
71
|
+
widgets?: WidgetConfig[];
|
|
70
72
|
isConfirmed?: boolean;
|
|
71
73
|
}
|
package/models/UserAP.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adminizer",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.1.0-build.
|
|
4
|
+
"version": "4.1.0-build.13",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"body-parser": "^1.20.3",
|
|
31
31
|
"chalk": "^5.4.1",
|
|
32
32
|
"cmdk": "^1.1.1",
|
|
33
|
+
"cookie": "^1.0.2",
|
|
33
34
|
"cookie-parser": "^1.4.7",
|
|
34
35
|
"cors": "^2.8.5",
|
|
35
36
|
"crypto-puzzle": "^5.0.2",
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
"ejs": "^3.1.10",
|
|
38
39
|
"express": "^4.21.2",
|
|
39
40
|
"express-session": "^1.18.1",
|
|
41
|
+
"jsonwebtoken": "^9.0.2",
|
|
40
42
|
"ky": "^1.8.0",
|
|
41
43
|
"multer": "^1.4.5-lts.1",
|
|
42
44
|
"next-themes": "^0.4.6",
|
|
@@ -74,6 +76,7 @@
|
|
|
74
76
|
"@types/express-session": "^1.18.1",
|
|
75
77
|
"@types/he": "^1.2.3",
|
|
76
78
|
"@types/json-schema": "^7.0.15",
|
|
79
|
+
"@types/jsonwebtoken": "^9.0.9",
|
|
77
80
|
"@types/leaflet": "^1.9.17",
|
|
78
81
|
"@types/lodash-es": "^4.17.12",
|
|
79
82
|
"@types/multer": "^1.4.12",
|
|
@@ -106,9 +109,12 @@
|
|
|
106
109
|
"react-simple-wysiwyg": "^3.2.2",
|
|
107
110
|
"sails-disk": "^2.1.2",
|
|
108
111
|
"sails-postgresql": "^5.0.1",
|
|
112
|
+
"sequelize": "^6.37.5",
|
|
113
|
+
"sequelize-typescript": "^2.1.6",
|
|
109
114
|
"shelljs": "^0.9.2",
|
|
110
115
|
"sonner": "^2.0.3",
|
|
111
116
|
"sprintf-js": "^1.1.3",
|
|
117
|
+
"sqlite3": "^5.1.7",
|
|
112
118
|
"tailwind-merge": "^3.0.2",
|
|
113
119
|
"tailwindcss": "^4.0.15",
|
|
114
120
|
"tsx": "^4.19.3",
|
|
@@ -117,9 +123,6 @@
|
|
|
117
123
|
"vanilla-jsoneditor": "^3.1.1",
|
|
118
124
|
"vite": "^6.1.0",
|
|
119
125
|
"vite-plugin-externals": "^0.6.2",
|
|
120
|
-
"vite-plugin-full-reload": "^1.2.0"
|
|
121
|
-
"sqlite3": "^5.1.7",
|
|
122
|
-
"sequelize": "^6.37.5",
|
|
123
|
-
"sequelize-typescript": "^2.1.6"
|
|
126
|
+
"vite-plugin-full-reload": "^1.2.0"
|
|
124
127
|
}
|
|
125
128
|
}
|
package/policies/checkAuth.js
CHANGED
|
@@ -4,12 +4,13 @@ export default async function checkAuth(req, res, proceed) {
|
|
|
4
4
|
locale = req.adminizer.config.translation.defaultLocale;
|
|
5
5
|
}
|
|
6
6
|
if (!req.adminizer.config.auth.enable) {
|
|
7
|
-
if (req.
|
|
8
|
-
req.
|
|
7
|
+
if (req.user) {
|
|
8
|
+
req.user.isAdministrator = true;
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
|
-
req.
|
|
11
|
+
req.user = {
|
|
12
12
|
id: 0,
|
|
13
|
+
login: "No Auth",
|
|
13
14
|
isAdministrator: true,
|
|
14
15
|
locale: locale
|
|
15
16
|
};
|
package/policies/setLocale.js
CHANGED
|
@@ -5,8 +5,8 @@ export default async function setLocale(req, res, proceed) {
|
|
|
5
5
|
if (typeof req.adminizer.config.translation === 'boolean') {
|
|
6
6
|
return proceed();
|
|
7
7
|
}
|
|
8
|
-
if (req.
|
|
9
|
-
req.i18n.setLocale(req.
|
|
8
|
+
if (req.user && req.user.locale) {
|
|
9
|
+
req.i18n.setLocale(req.user.locale);
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
12
12
|
req.i18n.setLocale(req.adminizer.config.translation.defaultLocale);
|
package/system/Router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _processInstallStep from "../controllers/processInstallStep";
|
|
2
|
-
import _processInstallFinalize from "../controllers/processInstallFinalize";
|
|
1
|
+
// import _processInstallStep from "../controllers/processInstallStep";
|
|
2
|
+
// import _processInstallFinalize from "../controllers/processInstallFinalize";
|
|
3
3
|
import _dashboard from "../controllers/dashboard";
|
|
4
4
|
import _welcome from "../controllers/welcome";
|
|
5
5
|
import _list from "../controllers/list";
|
|
@@ -59,12 +59,12 @@ export default class Router {
|
|
|
59
59
|
* Widgets Custom
|
|
60
60
|
*/
|
|
61
61
|
adminizer.app.all(`/widgets-action/:widgetId`, adminizer.policyManager.bindPolicies(policies, widgetCustomController));
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
adminizer.app.all(`/install/:id`, adminizer.policyManager.bindPolicies(policies, _processInstallStep));
|
|
67
|
-
adminizer.app.all(`/install/:id/finalize`, adminizer.policyManager.bindPolicies(policies, _processInstallFinalize));
|
|
62
|
+
// /**
|
|
63
|
+
// * Module Install Stepper
|
|
64
|
+
// * @deprecated
|
|
65
|
+
// * */
|
|
66
|
+
// adminizer.app.all(`/install/:id`, adminizer.policyManager.bindPolicies(policies, _processInstallStep));
|
|
67
|
+
// adminizer.app.all(`/install/:id/finalize`, adminizer.policyManager.bindPolicies(policies, _processInstallFinalize));
|
|
68
68
|
/**
|
|
69
69
|
* Edit form
|
|
70
70
|
* */
|
|
@@ -25,8 +25,7 @@ export default async function bindAuthorization(adminizer) {
|
|
|
25
25
|
for (let admin of admins) {
|
|
26
26
|
adminsCredentials.push({
|
|
27
27
|
fullName: admin.fullName,
|
|
28
|
-
login: admin.login
|
|
29
|
-
password: admin.password
|
|
28
|
+
login: admin.login
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
Adminizer.log.debug(`Has Administrators with login [${adminsCredentials[0].login}]`);
|