daveappserver 0.7.6 → 0.7.8
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/appserver.js +37 -8
- package/package.json +1 -1
package/appserver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var myVersion = "0.7.
|
|
1
|
+
var myVersion = "0.7.8", myProductName = "daveAppServer";
|
|
2
2
|
|
|
3
3
|
exports.start = startup;
|
|
4
4
|
exports.notifySocketSubscribers = notifySocketSubscribers;
|
|
@@ -1276,6 +1276,35 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
1276
1276
|
}
|
|
1277
1277
|
});
|
|
1278
1278
|
}
|
|
1279
|
+
//wordpress -- 10/31/23 by DW
|
|
1280
|
+
function wordpressHandleRequest (theRequest) {
|
|
1281
|
+
function encode (s) {
|
|
1282
|
+
return (encodeURIComponent (s));
|
|
1283
|
+
}
|
|
1284
|
+
function returnRedirect (url, code=302) {
|
|
1285
|
+
var headers = {
|
|
1286
|
+
location: url
|
|
1287
|
+
};
|
|
1288
|
+
theRequest.httpReturn (code, "text/plain", code + " REDIRECT", headers);
|
|
1289
|
+
}
|
|
1290
|
+
function useWordpressAccount (accessToken, theUserInfo) {
|
|
1291
|
+
console.log ("useWordpressAccount: accessToken == " + accessToken);
|
|
1292
|
+
console.log ("useWordpressAccount: theUserInfo == " + utils.jsonStringify (theUserInfo));
|
|
1293
|
+
config.loginWordpressUser (accessToken, theUserInfo, function (err, userRec) {
|
|
1294
|
+
if (err) {
|
|
1295
|
+
returnRedirect (config.urlServerForClient + "?failedLogin=true&message=" + encode (err.message));
|
|
1296
|
+
}
|
|
1297
|
+
else {
|
|
1298
|
+
returnRedirect (config.urlServerForClient + "?emailconfirmed=true&email=" + encode (userRec.emailAddress) + "&code=" + encode (userRec.emailSecret) + "&screenname=" + encode (userRec.screenname));
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
const options = {
|
|
1303
|
+
useWordpressAccount
|
|
1304
|
+
};
|
|
1305
|
+
const flHandled = wordpress.handleHttpRequest (theRequest, options);
|
|
1306
|
+
return (flHandled);
|
|
1307
|
+
}
|
|
1279
1308
|
|
|
1280
1309
|
function startup (options, callback) {
|
|
1281
1310
|
function readConfig (f, theConfig, flReportError, callback) {
|
|
@@ -1557,7 +1586,7 @@ function startup (options, callback) {
|
|
|
1557
1586
|
}
|
|
1558
1587
|
}
|
|
1559
1588
|
|
|
1560
|
-
if (
|
|
1589
|
+
if (wordpressHandleRequest (theRequest)) { //9/10/23 by DW
|
|
1561
1590
|
return (true);
|
|
1562
1591
|
}
|
|
1563
1592
|
|
|
@@ -1734,14 +1763,14 @@ function startup (options, callback) {
|
|
|
1734
1763
|
return (false);
|
|
1735
1764
|
}
|
|
1736
1765
|
function http404Callback (theRequest) {
|
|
1766
|
+
function return404 () {
|
|
1767
|
+
theRequest.httpReturn (404, "text/plain", "Not found.");
|
|
1768
|
+
}
|
|
1769
|
+
function returnPlainText (s) {
|
|
1770
|
+
theRequest.httpReturn (200, "text/plain", s.toString ());
|
|
1771
|
+
}
|
|
1737
1772
|
if (config.flStorageEnabled) {
|
|
1738
1773
|
if (checkPathForIllegalChars (theRequest.path)) {
|
|
1739
|
-
function return404 () {
|
|
1740
|
-
theRequest.httpReturn (404, "text/plain", "Not found.");
|
|
1741
|
-
}
|
|
1742
|
-
function returnPlainText (s) {
|
|
1743
|
-
theRequest.httpReturn (200, "text/plain", s.toString ());
|
|
1744
|
-
}
|
|
1745
1774
|
|
|
1746
1775
|
function getFileContent (screenname, relpath, flprivate, callback) { //9/8/21 by DW
|
|
1747
1776
|
var f = getFilePath (screenname, relpath, flprivate);
|