daveappserver 0.7.8 → 0.7.10
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 +62 -10
- package/package.json +2 -2
package/appserver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var myVersion = "0.7.
|
|
1
|
+
var myVersion = "0.7.10", myProductName = "daveAppServer";
|
|
2
2
|
|
|
3
3
|
exports.start = startup;
|
|
4
4
|
exports.notifySocketSubscribers = notifySocketSubscribers;
|
|
@@ -71,11 +71,22 @@ var config = {
|
|
|
71
71
|
|
|
72
72
|
flUseDatabaseForConfirmations: false, //8/14/23 by DW
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
flAllowWordpressIdentity: true, //10/31/23 by DW
|
|
75
|
+
|
|
76
|
+
flEnableSupervisorMode: false, //11/3/23 by DW
|
|
77
|
+
|
|
78
|
+
findUserWithScreenname: function (screenname, callback) { //2/6/23 by DW
|
|
79
|
+
callback (false);
|
|
80
|
+
},
|
|
81
|
+
findUserWithEmail: function (emailaddress, callback) { //11/4/23 by DW
|
|
75
82
|
callback (false);
|
|
76
83
|
},
|
|
77
84
|
getScreenNameFromEmail: function (screenname, callback) { //2/7/23 by DW
|
|
78
85
|
callback (undefined, screenname);
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
isUserAdmin: function (emailaddress, callback) { //11/3/23 by DW
|
|
89
|
+
callback (false);
|
|
79
90
|
}
|
|
80
91
|
};
|
|
81
92
|
const fnameConfig = "config.json";
|
|
@@ -90,7 +101,6 @@ var stats = {
|
|
|
90
101
|
};
|
|
91
102
|
const fnameStats = "stats.json";
|
|
92
103
|
|
|
93
|
-
|
|
94
104
|
function userIsWhitelisted (screenname, callback) { //9/16/22 by DW
|
|
95
105
|
fs.readFile (fnameConfig, function (err, jsontext) {
|
|
96
106
|
var flWhitelisted = false;
|
|
@@ -382,7 +392,7 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
382
392
|
}
|
|
383
393
|
else {
|
|
384
394
|
var emailAddress = words [1], emailSecret = words [2];
|
|
385
|
-
config.
|
|
395
|
+
config.findUserWithEmail (emailAddress, function (flInDatabase, userRec) {
|
|
386
396
|
if (flInDatabase) {
|
|
387
397
|
conn.appData.emailAddress = userRec.emailAddress;
|
|
388
398
|
conn.appData.screenname = userRec.emailAddress;
|
|
@@ -1172,7 +1182,7 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
1172
1182
|
callback ({message});
|
|
1173
1183
|
}
|
|
1174
1184
|
else {
|
|
1175
|
-
config.
|
|
1185
|
+
config.findUserWithScreenname (screenname, function (flInDatabase) {
|
|
1176
1186
|
if (flInDatabase) {
|
|
1177
1187
|
const message = "Can't create the user \"" + screenname + "\" because there already is a user with that name."
|
|
1178
1188
|
callback ({message});
|
|
@@ -1299,9 +1309,14 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
1299
1309
|
}
|
|
1300
1310
|
});
|
|
1301
1311
|
}
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1312
|
+
|
|
1313
|
+
var options = undefined;
|
|
1314
|
+
if (config.flAllowWordpressIdentity) {
|
|
1315
|
+
options = {
|
|
1316
|
+
useWordpressAccount
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1305
1320
|
const flHandled = wordpress.handleHttpRequest (theRequest, options);
|
|
1306
1321
|
return (flHandled);
|
|
1307
1322
|
}
|
|
@@ -1532,6 +1547,40 @@ function startup (options, callback) {
|
|
|
1532
1547
|
}
|
|
1533
1548
|
}
|
|
1534
1549
|
function callWithScreenname (callback) {
|
|
1550
|
+
|
|
1551
|
+
function actingAsFilter (email, callback) { //11/3/23 by DW
|
|
1552
|
+
if (config.flEnableSupervisorMode) {
|
|
1553
|
+
if (params.actingas === undefined) {
|
|
1554
|
+
callback (email);
|
|
1555
|
+
}
|
|
1556
|
+
else {
|
|
1557
|
+
config.isUserAdmin (email, function (flAdmin, userRec) {
|
|
1558
|
+
if (flAdmin) {
|
|
1559
|
+
config.findUserWithScreenname (params.actingas, function (flInDatabase, userRec) {
|
|
1560
|
+
if (flInDatabase) {
|
|
1561
|
+
if (userRec.emailAddress === undefined) {
|
|
1562
|
+
callback (email);
|
|
1563
|
+
}
|
|
1564
|
+
else {
|
|
1565
|
+
callback (userRec.emailAddress);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
else {
|
|
1569
|
+
callback (email);
|
|
1570
|
+
}
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
else {
|
|
1574
|
+
callback (email);
|
|
1575
|
+
}
|
|
1576
|
+
});
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
else {
|
|
1580
|
+
callback (email);
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1535
1584
|
if (config.flUseTwitterIdentity) { //2/6/23 by DW
|
|
1536
1585
|
if (config.getScreenname === undefined) {
|
|
1537
1586
|
davetwitter.getScreenName (token, secret, function (screenname) {
|
|
@@ -1557,10 +1606,13 @@ function startup (options, callback) {
|
|
|
1557
1606
|
else {
|
|
1558
1607
|
if ((params.emailaddress !== undefined) && (params.emailcode !== undefined)) {
|
|
1559
1608
|
const email = utils.stringLower (params.emailaddress); //3/8/23 by DW
|
|
1560
|
-
config.
|
|
1609
|
+
config.findUserWithEmail (email, function (flInDatabase, userRec) {
|
|
1561
1610
|
if (flInDatabase) {
|
|
1562
1611
|
if (params.emailcode == userRec.emailSecret) {
|
|
1563
|
-
|
|
1612
|
+
actingAsFilter (email, function (whoActingAs) {
|
|
1613
|
+
console.log ("\nappserver: whoActingAs == " + whoActingAs + "\n");
|
|
1614
|
+
callback (whoActingAs);
|
|
1615
|
+
});
|
|
1564
1616
|
}
|
|
1565
1617
|
else {
|
|
1566
1618
|
const message = "Can't do what you wanted the correct email authentication wasn't provided.";
|
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.10",
|
|
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
|
}
|