nodebb-plugin-onekite-calendar 2.0.64 → 2.0.66

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 (3) hide show
  1. package/lib/api.js +49 -23
  2. package/package.json +1 -1
  3. package/plugin.json +1 -1
package/lib/api.js CHANGED
@@ -2,12 +2,9 @@
2
2
 
3
3
  const crypto = require('crypto');
4
4
 
5
- const meta = require.main.require('./src/meta');
6
5
  const nconf = require.main.require('nconf');
7
6
  const user = require.main.require('./src/user');
8
7
  const groups = require.main.require('./src/groups');
9
- const db = require.main.require('./src/database');
10
- const logger = require.main.require('./src/logger');
11
8
 
12
9
  const dbLayer = require('./db');
13
10
  const { getSettings } = require('./settings');
@@ -251,25 +248,26 @@ async function canCreateSpecial(uid, settings) {
251
248
  }
252
249
 
253
250
 
251
+ /**
252
+ * Determines if a user can join or leave special events as a participant.
253
+ *
254
+ * This permission is intentionally permissive: any authenticated user can participate
255
+ * in special events, regardless of group membership. This differs from creation/deletion
256
+ * permissions which remain restricted to specific groups.
257
+ *
258
+ * @param {number|string} uid - The user ID. Falsy values (0, null, undefined, '') indicate guest/unauthenticated users.
259
+ * @param {Object} settings - Plugin settings (unused but kept for API consistency with other permission functions).
260
+ * @returns {boolean} True if the user can join/leave special events (i.e., is authenticated).
261
+ *
262
+ * @since 1.0.0 Modified to allow all authenticated users (previously restricted to specific groups)
263
+ */
254
264
  async function canJoinSpecial(uid, settings) {
255
- if (!uid) return false;
256
- // Admins always allowed
257
- try {
258
- const isAdmin = await groups.isMember(uid, 'administrators');
259
- if (isAdmin) return true;
260
- } catch (e) {}
261
-
262
- // Special-event creators can join/leave
263
- if (await canCreateSpecial(uid, settings)) return true;
264
-
265
- // Location creator groups can also participate (even if they can't create events)
266
- const allowed = normalizeAllowedGroups(settings.creatorGroups || '');
267
- if (!allowed.length) return false;
268
- return userInAnyGroup(uid, allowed);
265
+ // Any authenticated user (non-zero uid) can participate in special events.
266
+ // The !! coercion converts truthy values to true, falsy to false.
267
+ return !!uid;
269
268
  }
270
269
 
271
270
 
272
-
273
271
  async function canDeleteSpecial(uid, settings) {
274
272
  if (!uid) return false;
275
273
  try {
@@ -767,13 +765,27 @@ api.getReservationDetails = async function (req, res) {
767
765
  return res.json(out);
768
766
  };
769
767
 
768
+ /**
769
+ * Get detailed information about a special event.
770
+ *
771
+ * This endpoint is publicly accessible (no authentication required).
772
+ * Guests can view all event details including participants, but cannot join (canJoin will be false).
773
+ *
774
+ * @route GET /api/v3/plugins/calendar-onekite/special-events/:eid
775
+ * @param {Object} req - Express request object with req.params.eid and optionally req.uid
776
+ * @param {Object} res - Express response object
777
+ * @returns {Object} Event details including participants list, calendar export links, and permission flags
778
+ *
779
+ * @since 1.0.0 Modified to allow unauthenticated access (guests can view)
780
+ */
770
781
  api.getSpecialEventDetails = async function (req, res) {
771
782
  const uid = req.uid;
772
- if (!uid) return res.status(401).json({ error: 'not-logged-in' });
783
+ // Guests (uid = null/undefined/0) can view event details but cannot join.
784
+ // Authenticated users get canJoin=true if they meet participation requirements.
773
785
 
774
786
  const settings = await getSettings();
775
- const canMod = await canValidate(uid, settings);
776
- const canSpecialDelete = await canDeleteSpecial(uid, settings);
787
+ const canMod = uid ? await canValidate(uid, settings) : false;
788
+ const canSpecialDelete = uid ? await canDeleteSpecial(uid, settings) : false;
777
789
 
778
790
  const eid = String(req.params.eid || '').trim();
779
791
  if (!eid) return res.status(400).json({ error: 'missing-eid' });
@@ -979,12 +991,26 @@ api.deleteSpecialEvent = async function (req, res) {
979
991
  res.json({ ok: true });
980
992
  };
981
993
 
994
+ /**
995
+ * Get detailed information about an outing (prévision de sortie).
996
+ *
997
+ * This endpoint is publicly accessible (no authentication required).
998
+ * Guests can view all outing details including participants, but cannot join (canJoin will be false).
999
+ *
1000
+ * @route GET /api/v3/plugins/calendar-onekite/outings/:oid
1001
+ * @param {Object} req - Express request object with req.params.oid and optionally req.uid
1002
+ * @param {Object} res - Express response object
1003
+ * @returns {Object} Outing details including participants list, calendar export links, and permission flags
1004
+ *
1005
+ * @since 1.0.0 Modified to allow unauthenticated access (guests can view)
1006
+ */
982
1007
  api.getOutingDetails = async function (req, res) {
983
1008
  const uid = req.uid;
984
- if (!uid) return res.status(401).json({ error: 'not-logged-in' });
1009
+ // Guests (uid = null/undefined/0) can view outing details but cannot join.
1010
+ // Only authenticated users in authorized groups can join outings (canRequest).
985
1011
 
986
1012
  const settings = await getSettings();
987
- const canMod = await canValidate(uid, settings);
1013
+ const canMod = uid ? await canValidate(uid, settings) : false;
988
1014
 
989
1015
  const oid = String(req.params.oid || '').trim();
990
1016
  if (!oid) return res.status(400).json({ error: 'missing-oid' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-onekite-calendar",
3
- "version": "2.0.64",
3
+ "version": "2.0.66",
4
4
  "description": "FullCalendar-based equipment reservation workflow with admin approval & HelloAsso payment for NodeBB",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -39,5 +39,5 @@
39
39
  "acpScripts": [
40
40
  "public/admin.js"
41
41
  ],
42
- "version": "2.0.64"
42
+ "version": "2.0.66"
43
43
  }