nodebb-plugin-session-sharing 7.1.2 → 7.1.4

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 (3) hide show
  1. package/README.md +1 -6
  2. package/library.js +10 -8
  3. package/package.json +5 -4
package/README.md CHANGED
@@ -18,11 +18,6 @@ if the requisite shared cookie is found (more on that below).
18
18
 
19
19
  You can use this plugin and single sign-on plugins together, but they won't be seamlessly integrated.
20
20
 
21
- ## Compatibility
22
-
23
- This plugin is compatible with NodeBB **v1.0.0 and up**. As of 27 January 2016, v1.0.0 has not been released
24
- yet, so you will need to be running the `master` branch of a NodeBB installation via GitHub.
25
-
26
21
  ## How does this work?
27
22
 
28
23
  This plugin checks incoming requests for a **shared cookie** that is saved by your application when a user
@@ -112,4 +107,4 @@ mode. NodeBB will then log in or create a user called "testUser", with the email
112
107
  might accidentally lock yourself out of the administrative account as you won't have a proper cookie to
113
108
  authenticate with. To reset the plugin settings, delete the "settings:session-sharing" hash/document in
114
109
  your data store. In a pinch, running `./nodebb reset -p nodebb-plugin-session-sharing` will work to disable
115
- the plugin so you can log back in.
110
+ the plugin so you can log back in.
package/library.js CHANGED
@@ -58,6 +58,8 @@ payloadKeys.forEach(function (key) {
58
58
  plugin.settings['payload:' + key] = key;
59
59
  });
60
60
 
61
+ plugin.defaults = Object.freeze({ ...plugin.settings });
62
+
61
63
  plugin.init = async (params) => {
62
64
  var router = params.router;
63
65
  var hostMiddleware = params.middleware;
@@ -99,7 +101,7 @@ SocketPlugins.sessionSharing.showUserIds = async (socket, data) => {
99
101
  throw new Error('no-uids-supplied');
100
102
  }
101
103
 
102
- return Promise.all(uids.map(async uid => db.getSortedSetRangeByScore(plugin.settings.name + ':uid', 0, -1, uid, uid)));
104
+ return Promise.all(uids.map(async (uid) => db.getSortedSetRangeByScore(plugin.settings.name + ':uid', 0, -1, uid, uid)));
103
105
  };
104
106
 
105
107
  SocketPlugins.sessionSharing.findUserByRemoteId = async (socket, data) => {
@@ -301,12 +303,12 @@ plugin.updateUserGroups = async (uid, userData) => {
301
303
  // Retrieve user groups
302
304
  let [userGroups] = await groups.getUserGroupsFromSet('groups:createtime', [uid]);
303
305
  // Normalize user group data to just group names
304
- userGroups = userGroups.map(groupObj => groupObj.name);
306
+ userGroups = userGroups.map((groupObj) => groupObj.name);
305
307
 
306
308
  // Build join and leave arrays
307
- let join = userData.groups.filter(name => !userGroups.includes(name));
309
+ let join = userData.groups.filter((name) => !userGroups.includes(name));
308
310
  if (plugin.settings.syncGroupList === 'on') {
309
- join = join.filter(group => plugin.settings.syncGroups.includes(group));
311
+ join = join.filter((group) => plugin.settings.syncGroups.includes(group));
310
312
  }
311
313
 
312
314
  let leave = userGroups.filter((name) => {
@@ -318,7 +320,7 @@ plugin.updateUserGroups = async (uid, userData) => {
318
320
  return !userData.groups.includes(name);
319
321
  });
320
322
  if (plugin.settings.syncGroupList === 'on') {
321
- leave = leave.filter(group => plugin.settings.syncGroups.includes(group));
323
+ leave = leave.filter((group) => plugin.settings.syncGroups.includes(group));
322
324
  }
323
325
 
324
326
  await executeJoinLeave(uid, join, leave);
@@ -331,14 +333,14 @@ async function executeJoinLeave(uid, join, leave) {
331
333
  return;
332
334
  }
333
335
 
334
- await Promise.all(join.map(name => groups.join(name, uid)));
336
+ await Promise.all(join.map((name) => groups.join(name, uid)));
335
337
  })(),
336
338
  (async () => {
337
339
  if (plugin.settings.syncGroupLeave !== 'on') {
338
340
  return;
339
341
  }
340
342
 
341
- await Promise.all(leave.map(name => groups.leave(name, uid)));
343
+ await Promise.all(leave.map((name) => groups.leave(name, uid)));
342
344
  })(),
343
345
  ]);
344
346
  }
@@ -566,7 +568,7 @@ plugin.reloadSettings = async (data) => {
566
568
  }
567
569
 
568
570
  winston.info('[session-sharing] Settings OK');
569
- plugin.settings = _.defaults(_.pickBy(settings, Boolean), plugin.settings);
571
+ plugin.settings = _.defaults(_.pickBy(settings, Boolean), plugin.defaults);
570
572
  plugin.ready = true;
571
573
  };
572
574
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-session-sharing",
3
- "version": "7.1.2",
3
+ "version": "7.1.4",
4
4
  "description": "Allows login sessions from your app to persist in NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
@@ -46,9 +46,10 @@
46
46
  "devDependencies": {
47
47
  "@commitlint/cli": "^9.1.2",
48
48
  "@commitlint/config-angular": "^7.1.2",
49
- "eslint": "^7.7.0",
50
- "eslint-config-airbnb-base": "^12.1.0",
51
- "eslint-plugin-import": "^2.8.0",
49
+ "eslint": "8.x",
50
+ "eslint-config-airbnb-base": "14.2.1",
51
+ "eslint-config-nodebb": "0.1.1",
52
+ "eslint-plugin-import": "2.x",
52
53
  "husky": "^2.4.0",
53
54
  "lint-staged": "^10.0.9",
54
55
  "request": "^2.88.2",