@saltcorn/server 0.8.7 → 0.8.8-beta.1
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/auth/admin.js +20 -16
- package/auth/routes.js +18 -13
- package/locales/en.json +45 -1
- package/locales/ru.json +145 -100
- package/locales/si.json +1197 -0
- package/package.json +8 -8
- package/public/diagram_utils.js +21 -1
- package/public/saltcorn-common.js +40 -19
- package/public/saltcorn.js +11 -5
- package/routes/actions.js +4 -3
- package/routes/admin.js +2 -0
- package/routes/common_lists.js +34 -19
- package/routes/diagram.js +214 -199
- package/routes/fields.js +118 -7
- package/routes/index.js +2 -0
- package/routes/menu.js +16 -9
- package/routes/models.js +492 -0
- package/routes/page.js +10 -6
- package/routes/tables.js +67 -41
- package/routes/view.js +10 -6
- package/routes/viewedit.js +27 -5
- package/tests/view.test.js +217 -0
package/auth/admin.js
CHANGED
|
@@ -55,9 +55,9 @@ module.exports = router;
|
|
|
55
55
|
*/
|
|
56
56
|
const getUserFields = async (req) => {
|
|
57
57
|
const userTable = Table.findOne({ name: "users" });
|
|
58
|
-
const userFields =
|
|
59
|
-
(
|
|
60
|
-
|
|
58
|
+
const userFields = userTable
|
|
59
|
+
.getFields()
|
|
60
|
+
.filter((f) => !f.calculated && f.name !== "id");
|
|
61
61
|
//console.log("userFields:",userFields);
|
|
62
62
|
const iterForm = async (cfgField) => {
|
|
63
63
|
const signup_form_name = getState().getConfig(cfgField, "");
|
|
@@ -242,6 +242,22 @@ router.get(
|
|
|
242
242
|
"/",
|
|
243
243
|
isAdmin,
|
|
244
244
|
error_catcher(async (req, res) => {
|
|
245
|
+
const auth_methods = getState().auth_methods;
|
|
246
|
+
const userBadges = (user) =>
|
|
247
|
+
span(
|
|
248
|
+
!!user.disabled &&
|
|
249
|
+
span({ class: "badge bg-danger me-1" }, req.__("Disabled")),
|
|
250
|
+
!!user.verified_on &&
|
|
251
|
+
span({ class: "badge bg-success me-1" }, req.__("Verified")),
|
|
252
|
+
Object.entries(auth_methods)
|
|
253
|
+
.filter(
|
|
254
|
+
([k, v]) =>
|
|
255
|
+
v.setsUserAttribute && user._attributes[v.setsUserAttribute]
|
|
256
|
+
)
|
|
257
|
+
.map(([k, v]) =>
|
|
258
|
+
span({ class: "badge bg-secondary me-1" }, v.label || k)
|
|
259
|
+
)
|
|
260
|
+
);
|
|
245
261
|
const users = await User.find({}, { orderBy: "id" });
|
|
246
262
|
const roles = await User.get_roles();
|
|
247
263
|
let roleMap = {};
|
|
@@ -278,19 +294,7 @@ router.get(
|
|
|
278
294
|
},
|
|
279
295
|
{
|
|
280
296
|
label: "",
|
|
281
|
-
key:
|
|
282
|
-
r.disabled
|
|
283
|
-
? span({ class: "badge bg-danger" }, req.__("Disabled"))
|
|
284
|
-
: "",
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
label: req.__("Verified"),
|
|
288
|
-
key: (r) =>
|
|
289
|
-
r.verified_on
|
|
290
|
-
? i({
|
|
291
|
-
class: "fas fa-check-circle text-success",
|
|
292
|
-
})
|
|
293
|
-
: "",
|
|
297
|
+
key: userBadges,
|
|
294
298
|
},
|
|
295
299
|
{ label: req.__("Role"), key: (r) => roleMap[r.role_id] },
|
|
296
300
|
{
|
package/auth/routes.js
CHANGED
|
@@ -224,7 +224,7 @@ const getAuthLinks = (current, noMethods) => {
|
|
|
224
224
|
* @param {*} saltcornApp
|
|
225
225
|
* @param {*} res
|
|
226
226
|
*/
|
|
227
|
-
const loginWithJwt = async (email, password, saltcornApp, res) => {
|
|
227
|
+
const loginWithJwt = async (email, password, saltcornApp, res, req) => {
|
|
228
228
|
const loginFn = async () => {
|
|
229
229
|
const publicUserLink = getState().getConfig("public_user_link");
|
|
230
230
|
const jwt_secret = db.connectObj.jwt_secret;
|
|
@@ -254,7 +254,7 @@ const loginWithJwt = async (email, password, saltcornApp, res) => {
|
|
|
254
254
|
res.json(token);
|
|
255
255
|
} else {
|
|
256
256
|
res.json({
|
|
257
|
-
alerts: [{ type: "danger", msg: "Incorrect user or password" }],
|
|
257
|
+
alerts: [{ type: "danger", msg: req.__("Incorrect user or password") }],
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
260
|
} else if (publicUserLink) {
|
|
@@ -276,7 +276,7 @@ const loginWithJwt = async (email, password, saltcornApp, res) => {
|
|
|
276
276
|
res.json(token);
|
|
277
277
|
} else {
|
|
278
278
|
res.json({
|
|
279
|
-
alerts: [{ type: "danger", msg: "The public login is deactivated" }],
|
|
279
|
+
alerts: [{ type: "danger", msg: req.__("The public login is deactivated") }],
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
};
|
|
@@ -445,7 +445,7 @@ router.post(
|
|
|
445
445
|
req.flash("success", req.__("Email with password reset link sent"));
|
|
446
446
|
res.redirect("/auth/login");
|
|
447
447
|
};
|
|
448
|
-
if (!u) {
|
|
448
|
+
if (!u || !u.password) {
|
|
449
449
|
respond();
|
|
450
450
|
return;
|
|
451
451
|
}
|
|
@@ -986,7 +986,8 @@ router.post(
|
|
|
986
986
|
email,
|
|
987
987
|
password,
|
|
988
988
|
req.headers["x-saltcorn-app"],
|
|
989
|
-
res
|
|
989
|
+
res,
|
|
990
|
+
req
|
|
990
991
|
);
|
|
991
992
|
else signup_login_with_user(u, req, res);
|
|
992
993
|
}
|
|
@@ -1099,7 +1100,7 @@ router.get(
|
|
|
1099
1100
|
const { method } = req.params;
|
|
1100
1101
|
if (method === "jwt") {
|
|
1101
1102
|
const { email, password } = req.query;
|
|
1102
|
-
await loginWithJwt(email, password, req.headers["x-saltcorn-app"], res);
|
|
1103
|
+
await loginWithJwt(email, password, req.headers["x-saltcorn-app"], res, req);
|
|
1103
1104
|
} else {
|
|
1104
1105
|
const auth = getState().auth_methods[method];
|
|
1105
1106
|
if (auth) {
|
|
@@ -1339,12 +1340,16 @@ const userSettings = async ({ req, res, pwform, user }) => {
|
|
|
1339
1340
|
)
|
|
1340
1341
|
),
|
|
1341
1342
|
},
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1343
|
+
...(user.password
|
|
1344
|
+
? [
|
|
1345
|
+
{
|
|
1346
|
+
type: "card",
|
|
1347
|
+
title: req.__("Change password"),
|
|
1348
|
+
contents: renderForm(pwform, req.csrfToken()),
|
|
1349
|
+
},
|
|
1350
|
+
]
|
|
1351
|
+
: []),
|
|
1352
|
+
...(user.password && show2FAPolicy
|
|
1348
1353
|
? [
|
|
1349
1354
|
{
|
|
1350
1355
|
type: "card",
|
|
@@ -1560,7 +1565,7 @@ router.post(
|
|
|
1560
1565
|
loggedIn,
|
|
1561
1566
|
error_catcher(async (req, res) => {
|
|
1562
1567
|
const user = await User.findOne({ id: req.user.id });
|
|
1563
|
-
if (req.body.new_password) {
|
|
1568
|
+
if (req.body.new_password && user.password) {
|
|
1564
1569
|
const pwform = changPwForm(req);
|
|
1565
1570
|
|
|
1566
1571
|
pwform.fields[0].validator = (oldpw) => {
|
package/locales/en.json
CHANGED
|
@@ -1168,6 +1168,22 @@
|
|
|
1168
1168
|
"Tag Entries": "Tag Entries",
|
|
1169
1169
|
"Not a valid field name": "Not a valid field name",
|
|
1170
1170
|
"Set a default value for missing data": "Set a default value for missing data",
|
|
1171
|
+
"Create model": "Create model",
|
|
1172
|
+
"Models": "Models",
|
|
1173
|
+
"New model": "New model",
|
|
1174
|
+
"Show model": "Show model",
|
|
1175
|
+
"Model instances": "Model instances",
|
|
1176
|
+
"Trained": "Trained",
|
|
1177
|
+
"Train new instance": "Train new instance",
|
|
1178
|
+
"Train model": "Train model",
|
|
1179
|
+
"Train": "Train",
|
|
1180
|
+
"Report": "Report",
|
|
1181
|
+
"Model training report": "Model training report",
|
|
1182
|
+
"Model training error": "Model training error",
|
|
1183
|
+
"Training error": "Training error",
|
|
1184
|
+
"Model": "Model",
|
|
1185
|
+
"Model instance": "Model instance",
|
|
1186
|
+
"Prediction output": "Prediction output",
|
|
1171
1187
|
"Table triggers: ": "Table triggers: ",
|
|
1172
1188
|
"App name": "App name",
|
|
1173
1189
|
"App icon": "App icon",
|
|
@@ -1193,5 +1209,33 @@
|
|
|
1193
1209
|
"Prevent any deletion of parent rows": "Prevent any deletion of parent rows",
|
|
1194
1210
|
"If the parent row is deleted, set key fields on child rows to null": "If the parent row is deleted, set key fields on child rows to null",
|
|
1195
1211
|
"Link out?": "Link out?",
|
|
1196
|
-
"Show a link to open popup contents in new tab": "Show a link to open popup contents in new tab"
|
|
1212
|
+
"Show a link to open popup contents in new tab": "Show a link to open popup contents in new tab",
|
|
1213
|
+
"Model %s deleted": "Model %s deleted",
|
|
1214
|
+
"Model instance %s deleted": "Model instance %s deleted",
|
|
1215
|
+
"Action information saved": "Action information saved",
|
|
1216
|
+
"JavaScript code:": "JavaScript code:",
|
|
1217
|
+
"code here": "code here",
|
|
1218
|
+
"Page '%s' was loaded": "Page '%s' was loaded",
|
|
1219
|
+
"View '%s' was loaded": "View '%s' was loaded",
|
|
1220
|
+
"Error message": "Error message",
|
|
1221
|
+
"Error shown to user if uniqueness is violated": "Error shown to user if uniqueness is violated",
|
|
1222
|
+
"Protected": "Protected",
|
|
1223
|
+
"Set role to access": "Set role to access",
|
|
1224
|
+
"User must have this role or higher to update or create field values": "User must have this role or higher to update or create field values",
|
|
1225
|
+
"Disable on mobile": "Disable on mobile",
|
|
1226
|
+
"moment.js format specifier": "moment.js format specifier",
|
|
1227
|
+
"Primary button": "Primary button",
|
|
1228
|
+
"Secondary button": "Secondary button",
|
|
1229
|
+
"Success button": "Success button",
|
|
1230
|
+
"Danger button": "Danger button",
|
|
1231
|
+
"Primary outline button": "Primary outline button",
|
|
1232
|
+
"Secondary outline button": "Secondary outline button",
|
|
1233
|
+
"Standard": "Standard",
|
|
1234
|
+
"X-Small": "X-Small",
|
|
1235
|
+
"Block": "Block",
|
|
1236
|
+
"Large block": "Large block",
|
|
1237
|
+
"Formula for JavaScript object that will be added to state parameters": "Formula for JavaScript object that will be added to state parameters",
|
|
1238
|
+
"Alignment": "Alignment",
|
|
1239
|
+
"Click to edit?": "Click to edit?",
|
|
1240
|
+
"Format": "Format"
|
|
1197
1241
|
}
|