@saltcorn/server 0.8.7-beta.6 → 0.8.8-beta.0

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 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 = (userTable.getFields()).filter(
59
- (f) => !f.calculated && f.name !== "id"
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: (r) =>
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
@@ -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
  }
@@ -1339,12 +1339,16 @@ const userSettings = async ({ req, res, pwform, user }) => {
1339
1339
  )
1340
1340
  ),
1341
1341
  },
1342
- {
1343
- type: "card",
1344
- title: req.__("Change password"),
1345
- contents: renderForm(pwform, req.csrfToken()),
1346
- },
1347
- ...(show2FAPolicy
1342
+ ...(user.password
1343
+ ? [
1344
+ {
1345
+ type: "card",
1346
+ title: req.__("Change password"),
1347
+ contents: renderForm(pwform, req.csrfToken()),
1348
+ },
1349
+ ]
1350
+ : []),
1351
+ ...(user.password && show2FAPolicy
1348
1352
  ? [
1349
1353
  {
1350
1354
  type: "card",
@@ -1560,7 +1564,7 @@ router.post(
1560
1564
  loggedIn,
1561
1565
  error_catcher(async (req, res) => {
1562
1566
  const user = await User.findOne({ id: req.user.id });
1563
- if (req.body.new_password) {
1567
+ if (req.body.new_password && user.password) {
1564
1568
  const pwform = changPwForm(req);
1565
1569
 
1566
1570
  pwform.fields[0].validator = (oldpw) => {
package/load_plugins.js CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  const db = require("@saltcorn/data/db");
9
9
  const { PluginManager } = require("live-plugin-manager");
10
- const { getState } = require("@saltcorn/data/db/state");
10
+ const { getState, getRootState } = require("@saltcorn/data/db/state");
11
11
  const Plugin = require("@saltcorn/data/models/plugin");
12
12
  const fs = require("fs");
13
13
  const proc = require("child_process");
@@ -179,10 +179,23 @@ const loadAllPlugins = async () => {
179
179
  * @returns {Promise<void>}
180
180
  */
181
181
  const loadAndSaveNewPlugin = async (plugin, force, noSignalOrDB) => {
182
+ const tenants_unsafe_plugins = getRootState().getConfig(
183
+ "tenants_unsafe_plugins",
184
+ false
185
+ );
186
+ const isRoot = db.getTenantSchema() === db.connectObj.default_schema;
187
+ if (!isRoot && !tenants_unsafe_plugins) {
188
+ if (plugin.source !== "npm") return;
189
+ //get allowed plugins
190
+ const instore = await Plugin.store_plugins_available();
191
+ const safes = instore.filter((p) => !p.unsafe).map((p) => p.location);
192
+ if (!safes.includes(plugin.location)) return;
193
+ }
182
194
  const { version, plugin_module, location } = await requirePlugin(
183
195
  plugin,
184
196
  force
185
197
  );
198
+
186
199
  // install dependecies
187
200
  for (const loc of plugin_module.dependencies || []) {
188
201
  const existing = await Plugin.findOne({ location: loc });
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,17 @@
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"
1197
1225
  }