daveappserver 0.6.18 → 0.6.21
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 +40 -18
- package/package.json +1 -1
package/appserver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var myVersion = "0.6.
|
|
1
|
+
var myVersion = "0.6.21", myProductName = "daveAppServer";
|
|
2
2
|
|
|
3
3
|
exports.start = startup;
|
|
4
4
|
exports.notifySocketSubscribers = notifySocketSubscribers;
|
|
@@ -1006,18 +1006,37 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
1006
1006
|
});
|
|
1007
1007
|
}
|
|
1008
1008
|
//email registration -- 12/7/22 by DW
|
|
1009
|
-
function sendConfirmingEmail (email, screenname, flNewUser=false, callback) {
|
|
1009
|
+
function sendConfirmingEmail (email, screenname, flNewUser=false, urlRedirect, callback) {
|
|
1010
|
+
email = utils.stringLower (email); //3/8/23 by DW
|
|
1010
1011
|
function getScreenname (callback) {
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1012
|
+
function containsIllegalCharacter (name) { //3/17/23 by DW
|
|
1013
|
+
function isLegal (ch) {
|
|
1014
|
+
return (isAlpha (ch) || isNumeric (ch) || (ch == "_"));
|
|
1015
|
+
}
|
|
1016
|
+
for (var i = 0; i < name.length; i++) {
|
|
1017
|
+
let ch = name [i];
|
|
1018
|
+
if (!isLegal (ch)) {
|
|
1019
|
+
return (true);
|
|
1019
1020
|
}
|
|
1020
|
-
}
|
|
1021
|
+
}
|
|
1022
|
+
return (false);
|
|
1023
|
+
}
|
|
1024
|
+
if (flNewUser) { //the caller had to provide it
|
|
1025
|
+
if (containsIllegalCharacter (screenname)) { //3/17/23 by DW
|
|
1026
|
+
const message = "Can't create the user \"" + screenname + "\" because only alpha, numeric and underscore characters are allowed in names."
|
|
1027
|
+
callback ({message});
|
|
1028
|
+
}
|
|
1029
|
+
else {
|
|
1030
|
+
config.isUserInDatabase (screenname, function (flInDatabase) {
|
|
1031
|
+
if (flInDatabase) {
|
|
1032
|
+
const message = "Can't create the user \"" + screenname + "\" because there already is a user with that name."
|
|
1033
|
+
callback ({message});
|
|
1034
|
+
}
|
|
1035
|
+
else {
|
|
1036
|
+
callback (undefined, screenname);
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1021
1040
|
}
|
|
1022
1041
|
else { //we have to look it up
|
|
1023
1042
|
config.getScreenNameFromEmail (email, callback);
|
|
@@ -1037,6 +1056,7 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
1037
1056
|
flDeleted: false,
|
|
1038
1057
|
screenname,
|
|
1039
1058
|
flNewUser, //1/7/23 by DW
|
|
1059
|
+
urlRedirect, //3/3/23 by DW
|
|
1040
1060
|
when: new Date ()
|
|
1041
1061
|
};
|
|
1042
1062
|
stats.pendingConfirmations.push (obj);
|
|
@@ -1074,8 +1094,7 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
1074
1094
|
});
|
|
1075
1095
|
}
|
|
1076
1096
|
function receiveConfirmation (emailConfirmCode, callback) {
|
|
1077
|
-
|
|
1078
|
-
|
|
1097
|
+
var urlWebApp = config.urlServerForClient; //2/5/23 by DW
|
|
1079
1098
|
var urlRedirect = undefined, flFoundConfirm = false;
|
|
1080
1099
|
function encode (s) {
|
|
1081
1100
|
return (encodeURIComponent (s));
|
|
@@ -1083,6 +1102,9 @@ function cleanFileStats (stats) { //4/19/21 by DW
|
|
|
1083
1102
|
stats.pendingConfirmations.forEach (function (item) {
|
|
1084
1103
|
if (item.magicString == emailConfirmCode) {
|
|
1085
1104
|
if (config.addEmailToUserInDatabase !== undefined) {
|
|
1105
|
+
if (item.urlRedirect !== undefined) { //3/3/23 by DW
|
|
1106
|
+
urlWebApp = item.urlRedirect;
|
|
1107
|
+
}
|
|
1086
1108
|
config.addEmailToUserInDatabase (item.screenname, item.email, item.magicString, item.flNewUser, function (err, emailSecret) {
|
|
1087
1109
|
if (err) {
|
|
1088
1110
|
urlRedirect = urlWebApp + "?failedLogin=true&message=" + encode (err.message);
|
|
@@ -1339,7 +1361,6 @@ function startup (options, callback) {
|
|
|
1339
1361
|
}
|
|
1340
1362
|
}
|
|
1341
1363
|
function callWithScreenname (callback) {
|
|
1342
|
-
|
|
1343
1364
|
if (config.flUseTwitterIdentity) { //2/6/23 by DW
|
|
1344
1365
|
if (config.getScreenname === undefined) {
|
|
1345
1366
|
davetwitter.getScreenName (token, secret, function (screenname) {
|
|
@@ -1364,10 +1385,11 @@ function startup (options, callback) {
|
|
|
1364
1385
|
}
|
|
1365
1386
|
else {
|
|
1366
1387
|
if ((params.emailaddress !== undefined) && (params.emailcode !== undefined)) {
|
|
1367
|
-
|
|
1388
|
+
const email = utils.stringLower (params.emailaddress); //3/8/23 by DW
|
|
1389
|
+
config.isUserInDatabase (email, function (flInDatabase, userRec) {
|
|
1368
1390
|
if (flInDatabase) {
|
|
1369
1391
|
if (params.emailcode == userRec.emailSecret) {
|
|
1370
|
-
callback (
|
|
1392
|
+
callback (email);
|
|
1371
1393
|
}
|
|
1372
1394
|
else {
|
|
1373
1395
|
const message = "Can't do what you wanted the correct email authentication wasn't provided.";
|
|
@@ -1550,10 +1572,10 @@ function startup (options, callback) {
|
|
|
1550
1572
|
});
|
|
1551
1573
|
return (true);
|
|
1552
1574
|
case "/sendconfirmingemail": //12/7/22 by DW
|
|
1553
|
-
sendConfirmingEmail (params.email, undefined, false, httpReturn);
|
|
1575
|
+
sendConfirmingEmail (params.email, undefined, false, params.urlredirect, httpReturn); //3/3/23 by DW
|
|
1554
1576
|
return (true);
|
|
1555
1577
|
case "/createnewuser": //1/7/23 by DW
|
|
1556
|
-
sendConfirmingEmail (params.email, params.name, true, httpReturn);
|
|
1578
|
+
sendConfirmingEmail (params.email, params.name, true, params.urlredirect, httpReturn); //3/3/23 by DW
|
|
1557
1579
|
return (true);
|
|
1558
1580
|
case "/userconfirms": //12/7/22 by DW
|
|
1559
1581
|
receiveConfirmation (params.emailConfirmCode, httpReturnRedirect);
|