nodebb-plugin-session-sharing 8.0.0 → 8.0.1
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 -6
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -93,19 +93,27 @@ plugin.appendConfig = async (config) => {
|
|
|
93
93
|
SocketPlugins.sessionSharing = {};
|
|
94
94
|
|
|
95
95
|
SocketPlugins.sessionSharing.showUserIds = async (socket, data) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
if (!socket.uid || !data || !Array.isArray(data.uids)) {
|
|
97
|
+
throw new Error('[[error:invalid-data]]');
|
|
98
|
+
}
|
|
99
|
+
const isAdmin = await user.isAdministrator(socket.uid);
|
|
100
|
+
if (!isAdmin) {
|
|
101
|
+
throw new Error('[[error:no-privileges]]');
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
return Promise.all(
|
|
104
|
-
uids.map(
|
|
105
|
+
data.uids.map(uid => db.getSortedSetRangeByScore(`${plugin.settings.name}:uid`, 0, -1, uid, uid))
|
|
105
106
|
);
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
SocketPlugins.sessionSharing.findUserByRemoteId = async (socket, data) => {
|
|
110
|
+
if (!socket.uid || !data || !Array.isArray(data.uids)) {
|
|
111
|
+
throw new Error('[[error:invalid-data]]');
|
|
112
|
+
}
|
|
113
|
+
const isAdmin = await user.isAdministrator(socket.uid);
|
|
114
|
+
if (!isAdmin) {
|
|
115
|
+
throw new Error('[[error:no-privileges]]');
|
|
116
|
+
}
|
|
109
117
|
if (!data.remoteId) {
|
|
110
118
|
throw new Error('no-remote-id-supplied');
|
|
111
119
|
}
|
|
@@ -439,6 +447,7 @@ plugin.addMiddleware = async function ({ req, res }) {
|
|
|
439
447
|
const uid = await plugin.process(req.cookies[plugin.settings.cookieName]);
|
|
440
448
|
if (uid === req.uid) {
|
|
441
449
|
winston.verbose(`[session-sharing] Re-validated login for uid ${uid}, path ${req.originalUrl}`);
|
|
450
|
+
await nbbAuthController.onSuccessfulLogin(req, uid);
|
|
442
451
|
return;
|
|
443
452
|
}
|
|
444
453
|
|