daveappserver 0.7.9 → 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.
Files changed (2) hide show
  1. package/appserver.js +52 -6
  2. package/package.json +1 -1
package/appserver.js CHANGED
@@ -1,4 +1,4 @@
1
- var myVersion = "0.7.9", myProductName = "daveAppServer";
1
+ var myVersion = "0.7.10", myProductName = "daveAppServer";
2
2
 
3
3
  exports.start = startup;
4
4
  exports.notifySocketSubscribers = notifySocketSubscribers;
@@ -73,11 +73,20 @@ var config = {
73
73
 
74
74
  flAllowWordpressIdentity: true, //10/31/23 by DW
75
75
 
76
- isUserInDatabase: function (screenname, callback) { //2/6/23 by DW
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
77
82
  callback (false);
78
83
  },
79
84
  getScreenNameFromEmail: function (screenname, callback) { //2/7/23 by DW
80
85
  callback (undefined, screenname);
86
+ },
87
+
88
+ isUserAdmin: function (emailaddress, callback) { //11/3/23 by DW
89
+ callback (false);
81
90
  }
82
91
  };
83
92
  const fnameConfig = "config.json";
@@ -383,7 +392,7 @@ function cleanFileStats (stats) { //4/19/21 by DW
383
392
  }
384
393
  else {
385
394
  var emailAddress = words [1], emailSecret = words [2];
386
- config.isUserInDatabase (emailAddress, function (flInDatabase, userRec) {
395
+ config.findUserWithEmail (emailAddress, function (flInDatabase, userRec) {
387
396
  if (flInDatabase) {
388
397
  conn.appData.emailAddress = userRec.emailAddress;
389
398
  conn.appData.screenname = userRec.emailAddress;
@@ -1173,7 +1182,7 @@ function cleanFileStats (stats) { //4/19/21 by DW
1173
1182
  callback ({message});
1174
1183
  }
1175
1184
  else {
1176
- config.isUserInDatabase (screenname, function (flInDatabase) {
1185
+ config.findUserWithScreenname (screenname, function (flInDatabase) {
1177
1186
  if (flInDatabase) {
1178
1187
  const message = "Can't create the user \"" + screenname + "\" because there already is a user with that name."
1179
1188
  callback ({message});
@@ -1538,6 +1547,40 @@ function startup (options, callback) {
1538
1547
  }
1539
1548
  }
1540
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
+
1541
1584
  if (config.flUseTwitterIdentity) { //2/6/23 by DW
1542
1585
  if (config.getScreenname === undefined) {
1543
1586
  davetwitter.getScreenName (token, secret, function (screenname) {
@@ -1563,10 +1606,13 @@ function startup (options, callback) {
1563
1606
  else {
1564
1607
  if ((params.emailaddress !== undefined) && (params.emailcode !== undefined)) {
1565
1608
  const email = utils.stringLower (params.emailaddress); //3/8/23 by DW
1566
- config.isUserInDatabase (email, function (flInDatabase, userRec) {
1609
+ config.findUserWithEmail (email, function (flInDatabase, userRec) {
1567
1610
  if (flInDatabase) {
1568
1611
  if (params.emailcode == userRec.emailSecret) {
1569
- callback (email);
1612
+ actingAsFilter (email, function (whoActingAs) {
1613
+ console.log ("\nappserver: whoActingAs == " + whoActingAs + "\n");
1614
+ callback (whoActingAs);
1615
+ });
1570
1616
  }
1571
1617
  else {
1572
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.9",
4
+ "version": "0.7.10",
5
5
  "main": "appserver.js",
6
6
  "repository": {
7
7
  "type" : "git",