nodebb-plugin-ezoic-infinite 1.5.12 → 1.5.13
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 +8 -1
- package/package.json +1 -1
package/library.js
CHANGED
|
@@ -70,6 +70,12 @@ async function isUserExcluded(uid, excludedGroups) {
|
|
|
70
70
|
if (uid === undefined || uid === null || !excludedGroups.length) return false;
|
|
71
71
|
|
|
72
72
|
const excludedSet = new Set(excludedGroups.map(g => String(g).toLowerCase()));
|
|
73
|
+
// Guests: NodeBB often represents them as uid=0 and they may not have groups in the database.
|
|
74
|
+
if (uid === 0) {
|
|
75
|
+
return excludedSet.has('guests') || excludedSet.has('guest');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
73
79
|
const userGroups = await groups.getUserGroups([uid]);
|
|
74
80
|
return (userGroups[0] || []).some(g => {
|
|
75
81
|
const name = (g && g.name) ? g.name : g;
|
|
@@ -114,7 +120,8 @@ plugin.init = async ({ router, middleware }) => {
|
|
|
114
120
|
|
|
115
121
|
router.get('/api/plugins/ezoic-infinite/config', async (req, res) => {
|
|
116
122
|
const settings = await getSettings();
|
|
117
|
-
const
|
|
123
|
+
const uid = (typeof req.uid === 'number' ? req.uid : (req.user && typeof req.user.uid === 'number' ? req.user.uid : (res.locals && typeof res.locals.uid === 'number' ? res.locals.uid : 0)));
|
|
124
|
+
const excluded = await isUserExcluded(uid, settings.excludedGroups);
|
|
118
125
|
|
|
119
126
|
res.json({
|
|
120
127
|
excluded,
|