nodebb-plugin-session-sharing 7.0.1 → 7.1.0

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/library.js +5 -5
  2. package/package.json +1 -1
package/library.js CHANGED
@@ -420,13 +420,12 @@ plugin.addMiddleware = async function ({ req, res }) {
420
420
  if (Object.keys(req.cookies).length && req.cookies.hasOwnProperty(plugin.settings.cookieName) && req.cookies[plugin.settings.cookieName].length) {
421
421
  try {
422
422
  const uid = await plugin.process(req.cookies[plugin.settings.cookieName]);
423
- winston.verbose('[session-sharing] Processing login for uid ' + uid + ', path ' + req.originalUrl);
424
- req.uid = uid;
425
-
426
- if (plugin.settings.behaviour === 'revalidate' || plugin.settings.behaviour === 'update') {
427
- res.locals.reroll = false; // disable session rerolling in core
423
+ if (uid === req.uid) {
424
+ winston.verbose(`[session-sharing] Re-validated login for uid ${uid}, path ${req.originalUrl}`);
425
+ return;
428
426
  }
429
427
 
428
+ winston.verbose('[session-sharing] Processing login for uid ' + uid + ', path ' + req.originalUrl);
430
429
  await nbbAuthController.doLogin(req, uid);
431
430
 
432
431
  req.session.loginLock = true;
@@ -467,6 +466,7 @@ plugin.addMiddleware = async function ({ req, res }) {
467
466
  const isAdmin = await user.isAdministrator(req.user.uid);
468
467
 
469
468
  if (plugin.settings.behaviour !== 'update' && (plugin.settings.adminRevalidate === 'on' || !isAdmin)) {
469
+ winston.verbose(`[session-sharing] Found login session but no cookie, logging out user (was uid ${req.uid})`);
470
470
  await logoutAsync(req);
471
471
  res.locals.fullRefresh = true;
472
472
  return handleGuest(req, res);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-session-sharing",
3
- "version": "7.0.1",
3
+ "version": "7.1.0",
4
4
  "description": "Allows login sessions from your app to persist in NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {