@saltcorn/server 0.7.0-beta.3 → 0.7.0-beta.4
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/routes.js +56 -10
- package/locales/en.json +6 -1
- package/locales/it.json +3 -1
- package/package.json +7 -7
- package/public/gridedit.js +4 -0
- package/public/saltcorn.css +5 -1
- package/routes/admin.js +2 -1
- package/routes/api.js +4 -1
- package/routes/list.js +2 -2
package/auth/routes.js
CHANGED
|
@@ -41,6 +41,8 @@ const {
|
|
|
41
41
|
code,
|
|
42
42
|
pre,
|
|
43
43
|
p,
|
|
44
|
+
script,
|
|
45
|
+
domReady,
|
|
44
46
|
} = require("@saltcorn/markup/tags");
|
|
45
47
|
const {
|
|
46
48
|
available_languages,
|
|
@@ -416,6 +418,7 @@ router.get(
|
|
|
416
418
|
const form = loginForm(req, true);
|
|
417
419
|
form.action = "/auth/create_first_user";
|
|
418
420
|
form.submitLabel = req.__("Create user");
|
|
421
|
+
form.class = "create-first-user";
|
|
419
422
|
form.blurb = req.__(
|
|
420
423
|
"Please create your first user account, which will have administrative privileges. You can add other users and give them administrative privileges later."
|
|
421
424
|
);
|
|
@@ -424,7 +427,17 @@ router.get(
|
|
|
424
427
|
[i({ class: "fas fa-upload me-2 mt-2" }), req.__("Restore a backup")],
|
|
425
428
|
`/auth/create_from_restore`
|
|
426
429
|
);
|
|
427
|
-
res.sendAuthWrap(
|
|
430
|
+
res.sendAuthWrap(
|
|
431
|
+
req.__(`Create first user`),
|
|
432
|
+
form,
|
|
433
|
+
{},
|
|
434
|
+
restore +
|
|
435
|
+
script(
|
|
436
|
+
domReady(
|
|
437
|
+
`$('form.create-first-user button[type=submit]').click(function(){press_store_button(this)})`
|
|
438
|
+
)
|
|
439
|
+
)
|
|
440
|
+
);
|
|
428
441
|
} else {
|
|
429
442
|
req.flash("danger", req.__("Users already present"));
|
|
430
443
|
res.redirect("/auth/login");
|
|
@@ -1194,14 +1207,12 @@ const userSettings = async ({ req, res, pwform, user }) => {
|
|
|
1194
1207
|
),
|
|
1195
1208
|
div(
|
|
1196
1209
|
user._attributes.totp_enabled
|
|
1197
|
-
?
|
|
1198
|
-
"/auth/twofa/disable/totp",
|
|
1199
|
-
"Disable",
|
|
1200
|
-
req.csrfToken(),
|
|
1210
|
+
? a(
|
|
1201
1211
|
{
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
}
|
|
1212
|
+
href: "/auth/twofa/disable/totp",
|
|
1213
|
+
class: "btn btn-danger mt-2",
|
|
1214
|
+
},
|
|
1215
|
+
"Disable"
|
|
1205
1216
|
)
|
|
1206
1217
|
: a(
|
|
1207
1218
|
{
|
|
@@ -1552,6 +1563,7 @@ router.post(
|
|
|
1552
1563
|
if (!user._attributes.totp_key) {
|
|
1553
1564
|
//key not set
|
|
1554
1565
|
req.flash("danger", req.__("2FA TOTP Key not set"));
|
|
1566
|
+
console.log("2FA TOTP Key not set");
|
|
1555
1567
|
res.redirect("/auth/twofa/setup/totp");
|
|
1556
1568
|
return;
|
|
1557
1569
|
}
|
|
@@ -1560,6 +1572,8 @@ router.post(
|
|
|
1560
1572
|
form.validate(req.body);
|
|
1561
1573
|
if (form.hasErrors) {
|
|
1562
1574
|
req.flash("danger", req.__("Error processing form"));
|
|
1575
|
+
console.log("Error processing form");
|
|
1576
|
+
|
|
1563
1577
|
res.redirect("/auth/twofa/setup/totp");
|
|
1564
1578
|
return;
|
|
1565
1579
|
}
|
|
@@ -1569,6 +1583,7 @@ router.post(
|
|
|
1569
1583
|
});
|
|
1570
1584
|
if (!rv) {
|
|
1571
1585
|
req.flash("danger", req.__("Could not verify code"));
|
|
1586
|
+
console.log("Could not verify code");
|
|
1572
1587
|
res.redirect("/auth/twofa/setup/totp");
|
|
1573
1588
|
return;
|
|
1574
1589
|
}
|
|
@@ -1585,11 +1600,42 @@ router.post(
|
|
|
1585
1600
|
})
|
|
1586
1601
|
);
|
|
1587
1602
|
|
|
1603
|
+
router.get(
|
|
1604
|
+
"/twofa/disable/totp",
|
|
1605
|
+
loggedIn,
|
|
1606
|
+
error_catcher(async (req, res) => {
|
|
1607
|
+
res.sendWrap(req.__("Disable two-factor authentication"), {
|
|
1608
|
+
type: "card",
|
|
1609
|
+
title: req.__("Disable two-factor authentication"),
|
|
1610
|
+
contents: [
|
|
1611
|
+
h4(req.__("Enter your two-factor code in order to disable it")),
|
|
1612
|
+
renderForm(totpForm(req, "/auth/twofa/disable/totp"), req.csrfToken()),
|
|
1613
|
+
],
|
|
1614
|
+
});
|
|
1615
|
+
})
|
|
1616
|
+
);
|
|
1617
|
+
|
|
1588
1618
|
router.post(
|
|
1589
1619
|
"/twofa/disable/totp",
|
|
1590
1620
|
loggedIn,
|
|
1591
1621
|
error_catcher(async (req, res) => {
|
|
1592
1622
|
const user = await User.findOne({ id: req.user.id });
|
|
1623
|
+
const form = totpForm(req, "/auth/twofa/disable/totp");
|
|
1624
|
+
form.validate(req.body);
|
|
1625
|
+
if (form.hasErrors) {
|
|
1626
|
+
req.flash("danger", req.__("Error processing form"));
|
|
1627
|
+
res.redirect("/auth/twofa/disable/totp");
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
const code = `${form.values.totpCode}`;
|
|
1631
|
+
const rv = totp.verify(code, user._attributes.totp_key, {
|
|
1632
|
+
time: 30,
|
|
1633
|
+
});
|
|
1634
|
+
if (!rv) {
|
|
1635
|
+
req.flash("danger", req.__("Could not verify code"));
|
|
1636
|
+
res.redirect("/auth/twofa/disable/totp");
|
|
1637
|
+
return;
|
|
1638
|
+
}
|
|
1593
1639
|
user._attributes.totp_enabled = false;
|
|
1594
1640
|
delete user._attributes.totp_key;
|
|
1595
1641
|
await user.update({ _attributes: user._attributes });
|
|
@@ -1602,9 +1648,9 @@ router.post(
|
|
|
1602
1648
|
res.redirect("/auth/settings");
|
|
1603
1649
|
})
|
|
1604
1650
|
);
|
|
1605
|
-
const totpForm = (req) =>
|
|
1651
|
+
const totpForm = (req, action) =>
|
|
1606
1652
|
new Form({
|
|
1607
|
-
action: "/auth/twofa/setup/totp",
|
|
1653
|
+
action: action || "/auth/twofa/setup/totp",
|
|
1608
1654
|
fields: [
|
|
1609
1655
|
{
|
|
1610
1656
|
name: "totpCode",
|
package/locales/en.json
CHANGED
|
@@ -871,5 +871,10 @@
|
|
|
871
871
|
"Place in dropdown": "Place in dropdown",
|
|
872
872
|
"Hide null columns": "Hide null columns",
|
|
873
873
|
"Do not display a column if it contains entirely missing values": "Do not display a column if it contains entirely missing values",
|
|
874
|
-
"Show a warning to users creating a tenant disclaiming warrenty of availability or security": "Show a warning to users creating a tenant disclaiming warrenty of availability or security"
|
|
874
|
+
"Show a warning to users creating a tenant disclaiming warrenty of availability or security": "Show a warning to users creating a tenant disclaiming warrenty of availability or security",
|
|
875
|
+
"Set to 0 for expration at the end of browser session": "Set to 0 for expration at the end of browser session",
|
|
876
|
+
"Could not verify code": "Could not verify code",
|
|
877
|
+
"Disable two-factor authentication": "Disable two-factor authentication",
|
|
878
|
+
"Enter your two-factor code in order to disable it": "Enter your two-factor code in order to disable it",
|
|
879
|
+
"Allow the user to enter a new key that is not in the schema": "Allow the user to enter a new key that is not in the schema"
|
|
875
880
|
}
|
package/locales/it.json
CHANGED
|
@@ -475,5 +475,7 @@
|
|
|
475
475
|
"Events": "Events",
|
|
476
476
|
"Verified": "Verified",
|
|
477
477
|
"SSL": "SSL",
|
|
478
|
-
"Generate": "Generate"
|
|
478
|
+
"Generate": "Generate",
|
|
479
|
+
"Two-factor authentication": "Two-factor authentication",
|
|
480
|
+
"Two-factor authentication is disabled": "Two-factor authentication is disabled"
|
|
479
481
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.4",
|
|
4
4
|
"description": "Server app for Saltcorn, open-source no-code platform",
|
|
5
5
|
"homepage": "https://saltcorn.com",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@saltcorn/base-plugin": "0.7.0-beta.
|
|
10
|
-
"@saltcorn/builder": "0.7.0-beta.
|
|
11
|
-
"@saltcorn/data": "0.7.0-beta.
|
|
12
|
-
"@saltcorn/admin-models": "0.7.0-beta.
|
|
13
|
-
"@saltcorn/markup": "0.7.0-beta.
|
|
14
|
-
"@saltcorn/sbadmin2": "0.7.0-beta.
|
|
9
|
+
"@saltcorn/base-plugin": "0.7.0-beta.4",
|
|
10
|
+
"@saltcorn/builder": "0.7.0-beta.4",
|
|
11
|
+
"@saltcorn/data": "0.7.0-beta.4",
|
|
12
|
+
"@saltcorn/admin-models": "0.7.0-beta.4",
|
|
13
|
+
"@saltcorn/markup": "0.7.0-beta.4",
|
|
14
|
+
"@saltcorn/sbadmin2": "0.7.0-beta.4",
|
|
15
15
|
"@socket.io/cluster-adapter": "^0.1.0",
|
|
16
16
|
"@socket.io/sticky": "^1.0.1",
|
|
17
17
|
"aws-sdk": "^2.1037.0",
|
package/public/gridedit.js
CHANGED
|
@@ -8,6 +8,10 @@ function lookupIntToString(cell, formatterParams, onRendered) {
|
|
|
8
8
|
const res = formatterParams.values[val];
|
|
9
9
|
return res;
|
|
10
10
|
}
|
|
11
|
+
function deleteIcon() {
|
|
12
|
+
//plain text value
|
|
13
|
+
return '<i class="far fa-trash-alt"></i>';
|
|
14
|
+
}
|
|
11
15
|
|
|
12
16
|
function flatpickerEditor(cell, onRendered, success, cancel, editorParams) {
|
|
13
17
|
var input = $("<input type='text'/>");
|
package/public/saltcorn.css
CHANGED
package/routes/admin.js
CHANGED
|
@@ -71,6 +71,7 @@ const {
|
|
|
71
71
|
} = require("../markup/admin");
|
|
72
72
|
const moment = require("moment");
|
|
73
73
|
const View = require("@saltcorn/data/models/view");
|
|
74
|
+
const { getConfigFile } = require("@saltcorn/data/db/connect");
|
|
74
75
|
|
|
75
76
|
/**
|
|
76
77
|
* @type {object}
|
|
@@ -99,7 +100,7 @@ const site_id_form = (req) =>
|
|
|
99
100
|
"page_custom_html",
|
|
100
101
|
"development_mode",
|
|
101
102
|
"log_sql",
|
|
102
|
-
"multitenancy_enabled",
|
|
103
|
+
...(getConfigFile() ? ["multitenancy_enabled"] : []),
|
|
103
104
|
],
|
|
104
105
|
action: "/admin",
|
|
105
106
|
submitLabel: req.__("Save"),
|
package/routes/api.js
CHANGED
|
@@ -139,7 +139,10 @@ router.get(
|
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
141
|
let dvs;
|
|
142
|
-
if (
|
|
142
|
+
if (
|
|
143
|
+
field.is_fkey ||
|
|
144
|
+
(field.type.name === "String" && field.attributes?.options)
|
|
145
|
+
) {
|
|
143
146
|
dvs = await field.distinct_values();
|
|
144
147
|
} else {
|
|
145
148
|
dvs = await table.distinctValues(fieldName);
|
package/routes/list.js
CHANGED