nodebb-plugin-session-sharing 8.0.1 → 8.0.2
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/library.js +15 -4
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -367,11 +367,19 @@ async function executeJoinLeave(uid, join, leave) {
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
plugin.createUser = async (userData) => {
|
|
370
|
-
|
|
370
|
+
const count = await db.incrObjectField('locks', `session-sharing-create:${userData.id}`);
|
|
371
|
+
if (count > 1) {
|
|
372
|
+
throw new Error('duplicate-creation');
|
|
373
|
+
}
|
|
374
|
+
try {
|
|
375
|
+
winston.verbose('[session-sharing] No user found, creating a new user for this login');
|
|
371
376
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
377
|
+
const uid = await user.create(_.pick(userData, profileFields));
|
|
378
|
+
await db.sortedSetAdd(plugin.settings.name + ':uid', uid, userData.id);
|
|
379
|
+
return uid;
|
|
380
|
+
} finally {
|
|
381
|
+
await db.deleteObjectFields('locks', [`session-sharing-create:${userData.id}`]);
|
|
382
|
+
}
|
|
375
383
|
};
|
|
376
384
|
|
|
377
385
|
plugin.addMiddleware = async function ({ req, res }) {
|
|
@@ -469,6 +477,9 @@ plugin.addMiddleware = async function ({ req, res }) {
|
|
|
469
477
|
winston.info('[session-sharing] Payload valid, but local account not found. Assuming guest.');
|
|
470
478
|
handleAsGuest = true;
|
|
471
479
|
break;
|
|
480
|
+
case 'duplicate-creation':
|
|
481
|
+
winston.warn('[session-sharing] Duplicate account creation attempt detected');
|
|
482
|
+
break;
|
|
472
483
|
default:
|
|
473
484
|
winston.warn('[session-sharing] Error encountered while parsing token: ' + error.message);
|
|
474
485
|
break;
|