daveappserver 0.7.7 → 0.7.9
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 +38 -3
- package/package.json +2 -2
package/appserver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var myVersion = "0.7.
|
|
1
|
+
var myVersion = "0.7.9", myProductName = "daveAppServer";
|
|
2
2
|
|
|
3
3
|
exports.start = startup;
|
|
4
4
|
exports.notifySocketSubscribers = notifySocketSubscribers;
|
|
@@ -71,6 +71,8 @@ var config = {
|
|
|
71
71
|
|
|
72
72
|
flUseDatabaseForConfirmations: false, //8/14/23 by DW
|
|
73
73
|
|
|
74
|
+
flAllowWordpressIdentity: true, //10/31/23 by DW
|
|
75
|
+
|
|
74
76
|
isUserInDatabase: function (screenname, callback) { //2/6/23 by DW
|
|
75
77
|
callback (false);
|
|
76
78
|
},
|
|
@@ -90,7 +92,6 @@ var stats = {
|
|
|
90
92
|
};
|
|
91
93
|
const fnameStats = "stats.json";
|
|
92
94
|
|
|
93
|
-
|
|
94
95
|
function userIsWhitelisted (screenname, callback) { //9/16/22 by DW
|
|
95
96
|
fs.readFile (fnameConfig, function (err, jsontext) {
|
|
96
97
|
var flWhitelisted = false;
|
|
@@ -1276,6 +1277,40 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
1276
1277
|
}
|
|
1277
1278
|
});
|
|
1278
1279
|
}
|
|
1280
|
+
//wordpress -- 10/31/23 by DW
|
|
1281
|
+
function wordpressHandleRequest (theRequest) {
|
|
1282
|
+
function encode (s) {
|
|
1283
|
+
return (encodeURIComponent (s));
|
|
1284
|
+
}
|
|
1285
|
+
function returnRedirect (url, code=302) {
|
|
1286
|
+
var headers = {
|
|
1287
|
+
location: url
|
|
1288
|
+
};
|
|
1289
|
+
theRequest.httpReturn (code, "text/plain", code + " REDIRECT", headers);
|
|
1290
|
+
}
|
|
1291
|
+
function useWordpressAccount (accessToken, theUserInfo) {
|
|
1292
|
+
console.log ("useWordpressAccount: accessToken == " + accessToken);
|
|
1293
|
+
console.log ("useWordpressAccount: theUserInfo == " + utils.jsonStringify (theUserInfo));
|
|
1294
|
+
config.loginWordpressUser (accessToken, theUserInfo, function (err, userRec) {
|
|
1295
|
+
if (err) {
|
|
1296
|
+
returnRedirect (config.urlServerForClient + "?failedLogin=true&message=" + encode (err.message));
|
|
1297
|
+
}
|
|
1298
|
+
else {
|
|
1299
|
+
returnRedirect (config.urlServerForClient + "?emailconfirmed=true&email=" + encode (userRec.emailAddress) + "&code=" + encode (userRec.emailSecret) + "&screenname=" + encode (userRec.screenname));
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
var options = undefined;
|
|
1305
|
+
if (config.flAllowWordpressIdentity) {
|
|
1306
|
+
options = {
|
|
1307
|
+
useWordpressAccount
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
const flHandled = wordpress.handleHttpRequest (theRequest, options);
|
|
1312
|
+
return (flHandled);
|
|
1313
|
+
}
|
|
1279
1314
|
|
|
1280
1315
|
function startup (options, callback) {
|
|
1281
1316
|
function readConfig (f, theConfig, flReportError, callback) {
|
|
@@ -1557,7 +1592,7 @@ function startup (options, callback) {
|
|
|
1557
1592
|
}
|
|
1558
1593
|
}
|
|
1559
1594
|
|
|
1560
|
-
if (
|
|
1595
|
+
if (wordpressHandleRequest (theRequest)) { //9/10/23 by DW
|
|
1561
1596
|
return (true);
|
|
1562
1597
|
}
|
|
1563
1598
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "daveappserver",
|
|
3
3
|
"description": "Factored code that was appearing in all my servers.",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.9",
|
|
5
5
|
"main": "appserver.js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type" : "git",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
"daves3": "*",
|
|
26
26
|
"davehttp": "*",
|
|
27
27
|
"davemail": "*",
|
|
28
|
-
"wpidentity": "
|
|
28
|
+
"wpidentity": "^0.4.11"
|
|
29
29
|
}
|
|
30
30
|
}
|