@saltcorn/server 0.9.6-beta.19 → 0.9.6-beta.20
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 +12 -7
- package/package.json +9 -9
- package/public/saltcorn-common.js +133 -53
package/auth/routes.js
CHANGED
|
@@ -1103,15 +1103,20 @@ router.post(
|
|
|
1103
1103
|
res.redirect("/auth/twofa/login/totp");
|
|
1104
1104
|
return;
|
|
1105
1105
|
}
|
|
1106
|
+
let maxAge = null;
|
|
1106
1107
|
if (req.session.cookie)
|
|
1107
1108
|
if (req.body.remember) {
|
|
1108
|
-
const setDur = +getState().getConfig("cookie_duration_remember",
|
|
1109
|
-
if (setDur)
|
|
1110
|
-
|
|
1109
|
+
const setDur = +getState().getConfig("cookie_duration_remember", 720);
|
|
1110
|
+
if (setDur) {
|
|
1111
|
+
maxAge = setDur * 60 * 60 * 1000;
|
|
1112
|
+
req.session.cookie.maxAge = maxAge;
|
|
1113
|
+
} else req.session.cookie.expires = false;
|
|
1111
1114
|
} else {
|
|
1112
|
-
const setDur = +getState().getConfig("cookie_duration",
|
|
1113
|
-
if (setDur)
|
|
1114
|
-
|
|
1115
|
+
const setDur = +getState().getConfig("cookie_duration", 720);
|
|
1116
|
+
if (setDur) {
|
|
1117
|
+
maxAge = setDur * 60 * 60 * 1000;
|
|
1118
|
+
req.session.cookie.maxAge = maxAge;
|
|
1119
|
+
} else req.session.cookie.expires = false;
|
|
1115
1120
|
}
|
|
1116
1121
|
const session_id = getSessionId(req);
|
|
1117
1122
|
|
|
@@ -1119,7 +1124,7 @@ router.post(
|
|
|
1119
1124
|
session_id,
|
|
1120
1125
|
old_session_id: req.old_session_id,
|
|
1121
1126
|
});
|
|
1122
|
-
res?.cookie?.("loggedin", "true");
|
|
1127
|
+
res?.cookie?.("loggedin", "true", maxAge ? { maxAge } : undefined);
|
|
1123
1128
|
req.flash("success", req.__("Welcome, %s!", req.user.email));
|
|
1124
1129
|
if (req.smr) {
|
|
1125
1130
|
const dbUser = await User.findOne({ id: req.user.id });
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "0.9.6-beta.
|
|
3
|
+
"version": "0.9.6-beta.20",
|
|
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
9
|
"@aws-sdk/client-s3": "^3.451.0",
|
|
10
|
-
"@saltcorn/base-plugin": "0.9.6-beta.
|
|
11
|
-
"@saltcorn/builder": "0.9.6-beta.
|
|
12
|
-
"@saltcorn/data": "0.9.6-beta.
|
|
13
|
-
"@saltcorn/admin-models": "0.9.6-beta.
|
|
14
|
-
"@saltcorn/filemanager": "0.9.6-beta.
|
|
15
|
-
"@saltcorn/markup": "0.9.6-beta.
|
|
16
|
-
"@saltcorn/plugins-loader": "0.9.6-beta.
|
|
17
|
-
"@saltcorn/sbadmin2": "0.9.6-beta.
|
|
10
|
+
"@saltcorn/base-plugin": "0.9.6-beta.20",
|
|
11
|
+
"@saltcorn/builder": "0.9.6-beta.20",
|
|
12
|
+
"@saltcorn/data": "0.9.6-beta.20",
|
|
13
|
+
"@saltcorn/admin-models": "0.9.6-beta.20",
|
|
14
|
+
"@saltcorn/filemanager": "0.9.6-beta.20",
|
|
15
|
+
"@saltcorn/markup": "0.9.6-beta.20",
|
|
16
|
+
"@saltcorn/plugins-loader": "0.9.6-beta.20",
|
|
17
|
+
"@saltcorn/sbadmin2": "0.9.6-beta.20",
|
|
18
18
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
19
19
|
"@socket.io/sticky": "^1.0.1",
|
|
20
20
|
"adm-zip": "0.5.10",
|
|
@@ -655,6 +655,138 @@ function escapeHtml(text) {
|
|
|
655
655
|
function reload_on_init() {
|
|
656
656
|
localStorage.setItem("reload_on_init", true);
|
|
657
657
|
}
|
|
658
|
+
|
|
659
|
+
function doMobileTransforms() {
|
|
660
|
+
const replaceAttr = (el, attr, web, mobile) => {
|
|
661
|
+
const jThis = $(el);
|
|
662
|
+
const skip = jThis.attr("skip-mobile-adjust");
|
|
663
|
+
if (!skip) {
|
|
664
|
+
const attrVal = jThis.attr(attr);
|
|
665
|
+
if (attrVal?.includes(web)) {
|
|
666
|
+
jThis.attr(attr, attrVal.replace(web, mobile));
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
const replacers = {
|
|
672
|
+
href: [
|
|
673
|
+
{
|
|
674
|
+
web: "javascript:history.back()",
|
|
675
|
+
mobile: "javascript:parent.goBack()",
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
web: "javascript:ajax_modal",
|
|
679
|
+
mobile: "javascript:mobile_modal",
|
|
680
|
+
},
|
|
681
|
+
],
|
|
682
|
+
onclick: [
|
|
683
|
+
{
|
|
684
|
+
web: "history.back()",
|
|
685
|
+
mobile: "parent.goBack()",
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
web: "ajax_modal",
|
|
689
|
+
mobile: "mobile_modal",
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
web: "ajax_post_",
|
|
693
|
+
mobile: "local_post_",
|
|
694
|
+
},
|
|
695
|
+
],
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
$("a").each(function () {
|
|
699
|
+
let path = $(this).attr("href") || "";
|
|
700
|
+
if (path.startsWith("http")) {
|
|
701
|
+
const url = new URL(path);
|
|
702
|
+
path = `${url.pathname}${url.search}`;
|
|
703
|
+
}
|
|
704
|
+
if (path.startsWith("/view/") || path.startsWith("/page/")) {
|
|
705
|
+
const jThis = $(this);
|
|
706
|
+
const skip = jThis.attr("skip-mobile-adjust");
|
|
707
|
+
if (!skip) {
|
|
708
|
+
jThis.removeAttr("href");
|
|
709
|
+
jThis.attr("onclick", `execLink('${path}')`);
|
|
710
|
+
if (jThis.find("i,img").length === 0 && !jThis.css("color")) {
|
|
711
|
+
jThis.css(
|
|
712
|
+
"color",
|
|
713
|
+
"rgba(var(--bs-link-color-rgb),var(--bs-link-opacity,1))"
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
} else if (path.includes("/files/serve/")) {
|
|
718
|
+
const tokens = path.split("/files/serve/");
|
|
719
|
+
if (tokens.length > 1)
|
|
720
|
+
$(this).attr("href", `javascript:openFile('${tokens[1]}')`);
|
|
721
|
+
} else if (path.includes("/files/download/")) {
|
|
722
|
+
const tokens = path.split("/files/download/");
|
|
723
|
+
if (tokens.length > 1)
|
|
724
|
+
$(this).attr(
|
|
725
|
+
"href",
|
|
726
|
+
`javascript:notifyAlert('File donwloads are not supported.')`
|
|
727
|
+
);
|
|
728
|
+
} else {
|
|
729
|
+
for (const [k, v] of Object.entries(replacers)) {
|
|
730
|
+
for ({ web, mobile } of v) replaceAttr(this, k, web, mobile);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
$("button").each(function () {
|
|
736
|
+
for (const [k, v] of Object.entries({ onclick: replacers.onclick })) {
|
|
737
|
+
for ({ web, mobile } of v) replaceAttr(this, k, v.web, v.mobile);
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
$("[mobile-img-path]").each(async function () {
|
|
742
|
+
if (parent.loadEncodedFile) {
|
|
743
|
+
const fileId = $(this).attr("mobile-img-path");
|
|
744
|
+
const base64Encoded = await parent.loadEncodedFile(fileId);
|
|
745
|
+
this.src = base64Encoded;
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
$("[mobile-bg-img-path]").each(async function () {
|
|
750
|
+
if (parent.loadEncodedFile) {
|
|
751
|
+
const fileId = $(this).attr("mobile-bg-img-path");
|
|
752
|
+
if (fileId) {
|
|
753
|
+
const base64Encoded = await parent.loadEncodedFile(fileId);
|
|
754
|
+
this.style.backgroundImage = `url("${base64Encoded}")`;
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
$("img:not([mobile-img-path]):not([mobile-bg-img-path])").each(
|
|
760
|
+
async function () {
|
|
761
|
+
if (parent.loadEncodedFile) {
|
|
762
|
+
const jThis = $(this);
|
|
763
|
+
const src = jThis.attr("src");
|
|
764
|
+
if (src?.includes("/files/serve/")) {
|
|
765
|
+
const tokens = src.split("/files/serve/");
|
|
766
|
+
if (tokens.length > 1) {
|
|
767
|
+
const fileId = tokens[1];
|
|
768
|
+
const base64Encoded = await parent.loadEncodedFile(fileId);
|
|
769
|
+
this.src = base64Encoded;
|
|
770
|
+
}
|
|
771
|
+
} else if (src?.includes("/files/resize/")) {
|
|
772
|
+
const tokens = src.split("/files/resize/");
|
|
773
|
+
if (tokens.length > 1) {
|
|
774
|
+
const idAndDims = tokens[1].split("/");
|
|
775
|
+
const width = idAndDims[0];
|
|
776
|
+
const height = idAndDims.length > 2 ? idAndDims[1] : undefined;
|
|
777
|
+
const fileId = idAndDims[idAndDims.length - 1];
|
|
778
|
+
const style = { width: `${width || 50}px` };
|
|
779
|
+
if (height > 0) style.height = `${height}px`;
|
|
780
|
+
const base64Encoded = await parent.loadEncodedFile(fileId);
|
|
781
|
+
this.src = base64Encoded;
|
|
782
|
+
jThis.css(style);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
|
|
658
790
|
function initialize_page() {
|
|
659
791
|
if (window._sc_locale && window.dayjs) dayjs.locale(window._sc_locale);
|
|
660
792
|
const isNode = getIsNode();
|
|
@@ -829,59 +961,7 @@ function initialize_page() {
|
|
|
829
961
|
</form>`
|
|
830
962
|
);
|
|
831
963
|
});
|
|
832
|
-
if (!isNode)
|
|
833
|
-
$("[mobile-img-path]").each(async function () {
|
|
834
|
-
if (parent.loadEncodedFile) {
|
|
835
|
-
const fileId = $(this).attr("mobile-img-path");
|
|
836
|
-
const base64Encoded = await parent.loadEncodedFile(fileId);
|
|
837
|
-
this.src = base64Encoded;
|
|
838
|
-
}
|
|
839
|
-
});
|
|
840
|
-
|
|
841
|
-
$("[mobile-bg-img-path]").each(async function () {
|
|
842
|
-
if (parent.loadEncodedFile) {
|
|
843
|
-
const fileId = $(this).attr("mobile-bg-img-path");
|
|
844
|
-
if (fileId) {
|
|
845
|
-
const base64Encoded = await parent.loadEncodedFile(fileId);
|
|
846
|
-
this.style.backgroundImage = `url("${base64Encoded}")`;
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
});
|
|
850
|
-
|
|
851
|
-
$("a").each(function () {
|
|
852
|
-
let path = $(this).attr("href") || "";
|
|
853
|
-
if (path.startsWith("http")) {
|
|
854
|
-
const url = new URL(path);
|
|
855
|
-
path = `${url.pathname}${url.search}`;
|
|
856
|
-
}
|
|
857
|
-
if (path.startsWith("/view/") || path.startsWith("/page/")) {
|
|
858
|
-
const jThis = $(this);
|
|
859
|
-
const skip = jThis.attr("skip-mobile-adjust");
|
|
860
|
-
if (!skip) {
|
|
861
|
-
jThis.removeAttr("href");
|
|
862
|
-
jThis.attr("onclick", `execLink('${path}')`);
|
|
863
|
-
if (jThis.find("i,img").length === 0 && !jThis.css("color")) {
|
|
864
|
-
jThis.css(
|
|
865
|
-
"color",
|
|
866
|
-
"rgba(var(--bs-link-color-rgb),var(--bs-link-opacity,1))"
|
|
867
|
-
);
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
});
|
|
872
|
-
|
|
873
|
-
$("img").each(async function () {
|
|
874
|
-
if (parent.loadEncodedFile) {
|
|
875
|
-
const jThis = $(this);
|
|
876
|
-
const src = jThis.attr("src");
|
|
877
|
-
if (src?.startsWith("/files/serve/")) {
|
|
878
|
-
const fileId = src.replace("/files/serve/", "");
|
|
879
|
-
const base64Encoded = await parent.loadEncodedFile(fileId);
|
|
880
|
-
this.src = base64Encoded;
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
});
|
|
884
|
-
}
|
|
964
|
+
if (!isNode) doMobileTransforms();
|
|
885
965
|
function setExplainer(that) {
|
|
886
966
|
var id = $(that).attr("id") + "_explainer";
|
|
887
967
|
|