nodebb-plugin-calendar-onekite 12.0.14 → 12.0.15
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/lib/api.js +18 -8
- package/package.json +1 -1
package/lib/api.js
CHANGED
|
@@ -205,11 +205,11 @@ function autoFormSlugForYear(year) {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
async function canRequest(uid, settings, startTs) {
|
|
208
|
-
if (!uid) return
|
|
208
|
+
if (!uid) return false;
|
|
209
209
|
|
|
210
210
|
// Always allow administrators to create.
|
|
211
211
|
try {
|
|
212
|
-
if (await groups.isMember(uid, 'administrators')) return
|
|
212
|
+
if (await groups.isMember(uid, 'administrators')) return true;
|
|
213
213
|
} catch (e) {}
|
|
214
214
|
|
|
215
215
|
const year = yearFromTs(startTs);
|
|
@@ -219,13 +219,23 @@ async function canRequest(uid, settings, startTs) {
|
|
|
219
219
|
const raw = settings.creatorGroups ?? settings.allowedGroups ?? [];
|
|
220
220
|
const extraGroups = normalizeAllowedGroups(raw);
|
|
221
221
|
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
const chk = await checkAnyMembership(uid, allowed, 'canRequest');
|
|
225
|
-
if (chk.ok) return { ok: true, allowed, candidates: chk.candidates, startTs };
|
|
222
|
+
const allowedSlugs = [...new Set([defaultGroup, ...extraGroups].filter(Boolean))];
|
|
226
223
|
|
|
227
|
-
|
|
228
|
-
|
|
224
|
+
// Use getUserGroups (returns group objects) and compare slugs.
|
|
225
|
+
try {
|
|
226
|
+
const ug = await groups.getUserGroups([uid]);
|
|
227
|
+
const list = (ug && ug[0]) ? ug[0] : [];
|
|
228
|
+
const userSlugs = list.map(g => (g && g.slug) ? String(g.slug) : '').filter(Boolean);
|
|
229
|
+
return allowedSlugs.some(s => userSlugs.includes(s));
|
|
230
|
+
} catch (e) {
|
|
231
|
+
// Fallback: try isMember on each allowed slug (some installs accept slug)
|
|
232
|
+
for (const g of allowedSlugs) {
|
|
233
|
+
try {
|
|
234
|
+
if (await groups.isMember(uid, g)) return true;
|
|
235
|
+
} catch (err) {}
|
|
236
|
+
}
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
229
239
|
}
|
|
230
240
|
|
|
231
241
|
async function canValidate(uid, settings) {
|
package/package.json
CHANGED