daveappserver 0.6.9 → 0.6.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 +74 -24
- package/package.json +1 -1
package/appserver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var myVersion = "0.6.
|
|
1
|
+
var myVersion = "0.6.10", myProductName = "daveAppServer";
|
|
2
2
|
|
|
3
3
|
exports.start = startup;
|
|
4
4
|
exports.notifySocketSubscribers = notifySocketSubscribers;
|
|
@@ -41,6 +41,7 @@ var config = {
|
|
|
41
41
|
flEnableLogin: true, //user can log in via twitter
|
|
42
42
|
blockedAddresses: [],
|
|
43
43
|
flForceTwitterLogin: true,
|
|
44
|
+
flUseTwitterIdentity: false, //2/6/23 by DW
|
|
44
45
|
|
|
45
46
|
flStorageEnabled: true,
|
|
46
47
|
privateFilesPath: "privateFiles/users/",
|
|
@@ -57,7 +58,14 @@ var config = {
|
|
|
57
58
|
operationToConfirm: "add your email address to your FeedLand user profile",
|
|
58
59
|
mailSender: "dave@scripting.com",
|
|
59
60
|
dataFolder: "data/",
|
|
60
|
-
confirmationExpiresAfter: 60 * 60 //emails expire after an hour
|
|
61
|
+
confirmationExpiresAfter: 60 * 60, //emails expire after an hour
|
|
62
|
+
|
|
63
|
+
isUserInDatabase: function (screenname, callback) { //2/6/23 by DW
|
|
64
|
+
callback (false);
|
|
65
|
+
},
|
|
66
|
+
getScreenNameFromEmail: function (screenname, callback) { //2/7/23 by DW
|
|
67
|
+
callback (undefined, screenname);
|
|
68
|
+
}
|
|
61
69
|
};
|
|
62
70
|
const fnameConfig = "config.json";
|
|
63
71
|
|
|
@@ -934,7 +942,15 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
934
942
|
function sendConfirmingEmail (email, screenname, flNewUser=false, callback) {
|
|
935
943
|
function getScreenname (callback) {
|
|
936
944
|
if (flNewUser) { //the caller had to provide it
|
|
937
|
-
|
|
945
|
+
config.isUserInDatabase (screenname, function (flInDatabase) {
|
|
946
|
+
if (flInDatabase) {
|
|
947
|
+
const message = "Can't create the user \"" + screenname + "\" because there already is a user with that name."
|
|
948
|
+
callback ({message});
|
|
949
|
+
}
|
|
950
|
+
else {
|
|
951
|
+
callback (undefined, screenname);
|
|
952
|
+
}
|
|
953
|
+
});
|
|
938
954
|
}
|
|
939
955
|
else { //we have to look it up
|
|
940
956
|
config.getScreenNameFromEmail (email, callback);
|
|
@@ -946,7 +962,7 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
946
962
|
}
|
|
947
963
|
else {
|
|
948
964
|
const magicString = utils.getRandomPassword (10);
|
|
949
|
-
const urlWebApp =
|
|
965
|
+
const urlWebApp = config.urlServerForEmail; //2/6/23 by DW
|
|
950
966
|
console.log ("sendConfirmingEmail: email == " + email + ", urlWebApp == " + urlWebApp);
|
|
951
967
|
var obj = {
|
|
952
968
|
magicString: magicString,
|
|
@@ -991,7 +1007,8 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
991
1007
|
});
|
|
992
1008
|
}
|
|
993
1009
|
function receiveConfirmation (emailConfirmCode, callback) {
|
|
994
|
-
const urlWebApp =
|
|
1010
|
+
const urlWebApp = config.urlServerForClient; //2/5/23 by DW
|
|
1011
|
+
|
|
995
1012
|
var urlRedirect = undefined, flFoundConfirm = false;
|
|
996
1013
|
function encode (s) {
|
|
997
1014
|
return (encodeURIComponent (s));
|
|
@@ -1004,7 +1021,7 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
1004
1021
|
urlRedirect = urlWebApp + "?failedLogin=true&message=" + encode (err.message);
|
|
1005
1022
|
}
|
|
1006
1023
|
else {
|
|
1007
|
-
urlRedirect = urlWebApp + "?emailconfirmed=true&email=" + item.email + "&code=" + encode (emailSecret) + "&screenname=" + encode (item.screenname);
|
|
1024
|
+
urlRedirect = urlWebApp + "?emailconfirmed=true&email=" + encode (item.email) + "&code=" + encode (emailSecret) + "&screenname=" + encode (item.screenname);
|
|
1008
1025
|
item.flDeleted = true;
|
|
1009
1026
|
}
|
|
1010
1027
|
callback (urlRedirect);
|
|
@@ -1059,6 +1076,26 @@ function startup (options, callback) {
|
|
|
1059
1076
|
callback ();
|
|
1060
1077
|
});
|
|
1061
1078
|
}
|
|
1079
|
+
function readConfigJson (callback) { //2/8/23 by DW
|
|
1080
|
+
var configJs;
|
|
1081
|
+
try {
|
|
1082
|
+
configJs = require ("./config.js");
|
|
1083
|
+
}
|
|
1084
|
+
catch (err) { //try in the parent directory, assuming daveappserver is running in lib sub-directory
|
|
1085
|
+
try {
|
|
1086
|
+
configJs = require ("../config.js");
|
|
1087
|
+
}
|
|
1088
|
+
catch (err) { //fallback to reading config.json
|
|
1089
|
+
readConfig (fnameConfig, config, true, callback);
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
const jstruct = configJs;
|
|
1094
|
+
for (var x in jstruct) {
|
|
1095
|
+
config [x] = jstruct [x];
|
|
1096
|
+
}
|
|
1097
|
+
callback ();
|
|
1098
|
+
}
|
|
1062
1099
|
function startDavetwitter (httpRequestCallback) { //patch over a design problem in starting up davetwitter and davehttp -- 7/20/20 by DW
|
|
1063
1100
|
if (config.twitter === undefined) {
|
|
1064
1101
|
config.twitter = new Object ();
|
|
@@ -1188,6 +1225,7 @@ function startup (options, callback) {
|
|
|
1188
1225
|
flEnableLogin: config.flEnableLogin,
|
|
1189
1226
|
prefsPath: config.prefsPath,
|
|
1190
1227
|
docsPath: config.docsPath,
|
|
1228
|
+
flUseTwitterIdentity: config.flUseTwitterIdentity, //2/6/23 by DW
|
|
1191
1229
|
idGitHubClient: config.githubClientId //11/9/21 by DW
|
|
1192
1230
|
};
|
|
1193
1231
|
if (theRequest.addToPagetable !== undefined) { //3/9/21 by DW
|
|
@@ -1231,25 +1269,37 @@ function startup (options, callback) {
|
|
|
1231
1269
|
}
|
|
1232
1270
|
}
|
|
1233
1271
|
function callWithScreenname (callback) {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1272
|
+
|
|
1273
|
+
if (config.flUseTwitterIdentity) { //2/6/23 by DW
|
|
1274
|
+
if (config.getScreenname === undefined) {
|
|
1275
|
+
davetwitter.getScreenName (token, secret, function (screenname) {
|
|
1276
|
+
if (screenname === undefined) {
|
|
1277
|
+
returnError ({message: "Can't do the thing you want because the accessToken is not valid."});
|
|
1278
|
+
}
|
|
1279
|
+
else {
|
|
1280
|
+
callback (screenname);
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
else {
|
|
1285
|
+
config.getScreenname (params, function (err, screenname) { //12/23/22 by DW
|
|
1286
|
+
if (err) {
|
|
1287
|
+
returnError (err);
|
|
1288
|
+
}
|
|
1289
|
+
else {
|
|
1290
|
+
callback (screenname);
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1243
1294
|
}
|
|
1244
1295
|
else {
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
});
|
|
1296
|
+
if ((params.emailaddress !== undefined) && (params.emailcode !== undefined)) {
|
|
1297
|
+
callback (params.emailaddress); //obviously we have to check if it's valid
|
|
1298
|
+
}
|
|
1299
|
+
else {
|
|
1300
|
+
const message = "Can't do what you wanted because the call is missing email authentication.";
|
|
1301
|
+
returnError ({message});
|
|
1302
|
+
}
|
|
1253
1303
|
}
|
|
1254
1304
|
}
|
|
1255
1305
|
|
|
@@ -1509,7 +1559,7 @@ function startup (options, callback) {
|
|
|
1509
1559
|
}
|
|
1510
1560
|
|
|
1511
1561
|
utils.copyScalars (options, config); //1/22/21 by DW
|
|
1512
|
-
readConfig (fnameConfig, config, true, function () { //anything can be overridden by config.json
|
|
1562
|
+
readConfigJson (function () { //readConfig (fnameConfig, config, true, function () { //anything can be overridden by config.json
|
|
1513
1563
|
readConfig (fnameStats, stats, false, function () {
|
|
1514
1564
|
if (process.env.PORT !== undefined) { //8/6/20 by DW
|
|
1515
1565
|
config.port = process.env.PORT;
|