daveappserver 0.6.12 → 0.6.14

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.
Files changed (2) hide show
  1. package/appserver.js +41 -13
  2. package/package.json +1 -1
package/appserver.js CHANGED
@@ -1,4 +1,4 @@
1
- var myVersion = "0.6.12", myProductName = "daveAppServer";
1
+ var myVersion = "0.6.14", myProductName = "daveAppServer";
2
2
 
3
3
  exports.start = startup;
4
4
  exports.notifySocketSubscribers = notifySocketSubscribers;
@@ -335,6 +335,7 @@ function cleanFileStats (stats) { //4/19/21 by DW
335
335
  if (conn.appData !== undefined) { //it's one of ours
336
336
  if (conn != theNewConnection) { //it's not the new one
337
337
  if (conn.appData.screenname == screenname) {
338
+ console.log ("kissOtherLogonsGoodnight: \"" + conn.appData.screenname + "\" = \"" + screenname + "\""); //2/12/23 by DW
338
339
  conn.sendText ("goodnight");
339
340
  }
340
341
  }
@@ -344,7 +345,6 @@ function cleanFileStats (stats) { //4/19/21 by DW
344
345
 
345
346
  conn.on ("text", function (s) {
346
347
  var words = s.split (" ");
347
- console.log ("handleWebSocketConnection: s == " + s); //6/7/21 by DW
348
348
  if (words.length > 1) { //new protocol as of 11/29/15 by DW
349
349
  conn.appData.whenLastUpdate = now;
350
350
  conn.appData.lastVerb = words [0];
@@ -353,17 +353,31 @@ function cleanFileStats (stats) { //4/19/21 by DW
353
353
  conn.appData.urlToWatch = utils.trimWhitespace (words [1]);
354
354
  logToConsole (conn, conn.appData.lastVerb, conn.appData.urlToWatch);
355
355
  break;
356
-
357
356
  case "user": //9/29/21 by DW
358
- var token = words [1], secret = words [2];
359
- conn.appData.twOauthToken = token;
360
- conn.appData.twOauthTokenSecret = secret;
361
- conn.appData.urlToWatch = "";
362
- davetwitter.getScreenName (token, secret, function (screenname) {
363
- conn.appData.screenname = screenname;
364
- kissOtherLogonsGoodnight (screenname, conn); //12/14/21 by DW
365
- logToConsole (conn, conn.appData.lastVerb, conn.appData.screenname);
366
- });
357
+ if (config.flUseTwitterIdentity) { //2/12/23 by DW
358
+ var token = words [1], secret = words [2];
359
+ conn.appData.twOauthToken = token;
360
+ conn.appData.twOauthTokenSecret = secret;
361
+ conn.appData.urlToWatch = "";
362
+ davetwitter.getScreenName (token, secret, function (screenname) {
363
+ conn.appData.screenname = screenname;
364
+ kissOtherLogonsGoodnight (screenname, conn); //12/14/21 by DW
365
+ logToConsole (conn, conn.appData.lastVerb, conn.appData.screenname);
366
+ });
367
+ }
368
+ else {
369
+ var emailAddress = words [1], emailSecret = words [2];
370
+ config.isUserInDatabase (emailAddress, function (flInDatabase, userRec) {
371
+ if (flInDatabase) {
372
+ conn.appData.emailAddress = userRec.emailAddress;
373
+ conn.appData.screenname = userRec.emailAddress;
374
+ conn.appData.emailSecret = userRec.emailSecret;
375
+ conn.appData.urlToWatch = "";
376
+ kissOtherLogonsGoodnight (conn.appData.screenname, conn);
377
+ logToConsole (conn, conn.appData.lastVerb, conn.appData.screenname);
378
+ }
379
+ });
380
+ }
367
381
  break;
368
382
 
369
383
  }
@@ -1305,7 +1319,21 @@ function startup (options, callback) {
1305
1319
  }
1306
1320
  else {
1307
1321
  if ((params.emailaddress !== undefined) && (params.emailcode !== undefined)) {
1308
- callback (params.emailaddress); //obviously we have to check if it's valid
1322
+ config.isUserInDatabase (params.emailaddress, function (flInDatabase, userRec) {
1323
+ if (flInDatabase) {
1324
+ if (params.emailcode == userRec.emailSecret) {
1325
+ callback (params.emailaddress);
1326
+ }
1327
+ else {
1328
+ const message = "Can't do what you wanted the correct email authentication wasn't provided.";
1329
+ returnError ({message});
1330
+ }
1331
+ }
1332
+ else {
1333
+ const message = "Can't do what you wanted because the email address isn't in the database.";
1334
+ returnError ({message});
1335
+ }
1336
+ });
1309
1337
  }
1310
1338
  else {
1311
1339
  const message = "Can't do what you wanted because the call is missing email authentication.";
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.6.12",
4
+ "version": "0.6.14",
5
5
  "main": "appserver.js",
6
6
  "repository": {
7
7
  "type" : "git",