@communecter/cocolight-api-client 1.0.108 → 1.0.109

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@communecter/cocolight-api-client",
3
- "version": "1.0.108",
3
+ "version": "1.0.109",
4
4
  "description": "Client Axios simplifié pour l'API cocolight",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3793,10 +3793,12 @@ export class BaseEntity<TServerData = any> {
3793
3793
  /**
3794
3794
  * Vérifie si l'utilisateur est administrateur de l'entité.
3795
3795
  *
3796
+ * @param options - Options de vérification.
3797
+ * @param options.checkHierarchy - Si `true`, vérifie également si l'utilisateur est admin via la hiérarchie parent. Par défaut `false`.
3796
3798
  * @returns - `true` si l'utilisateur est administrateur, `false` sinon.
3797
3799
  * @throws {ApiError}
3798
3800
  */
3799
- isAdmin(): boolean {
3801
+ isAdmin(options?: { checkHierarchy?: boolean }): boolean {
3800
3802
  this._checkAccess("vérifier l'administrateur.");
3801
3803
  this._assertEntityType("organizations", "projects", "events");
3802
3804
 
@@ -3806,8 +3808,13 @@ export class BaseEntity<TServerData = any> {
3806
3808
  return true;
3807
3809
  }
3808
3810
 
3809
- // 2. Si pas de lien direct, remonter la hiérarchie parent
3810
- return this._isAdminViaHierarchy();
3811
+ // 2. Si pas de lien direct, remonter la hiérarchie parent (si activé)
3812
+ const checkHierarchy = options?.checkHierarchy ?? false;
3813
+ if (checkHierarchy) {
3814
+ return this._isAdminViaHierarchy();
3815
+ }
3816
+
3817
+ return false;
3811
3818
  }
3812
3819
 
3813
3820
  /**
package/src/api/Event.ts CHANGED
@@ -75,7 +75,7 @@ export class Event extends BaseEntity<EventItemNormalized> {
75
75
  };
76
76
 
77
77
  override _update = async (payload: Record<string, any>): Promise<boolean> => {
78
- if(!this.isAdmin()){
78
+ if(!this.isAdmin({ checkHierarchy: true })){
79
79
  throw new ApiError("Vous n'avez pas les droits pour modifier cet événement", 403);
80
80
  }
81
81
 
@@ -1276,10 +1276,14 @@ export declare class BaseEntity<TServerData = any> {
1276
1276
  /**
1277
1277
  * Vérifie si l'utilisateur est administrateur de l'entité.
1278
1278
  *
1279
+ * @param options - Options de vérification.
1280
+ * @param options.checkHierarchy - Si `true`, vérifie également si l'utilisateur est admin via la hiérarchie parent. Par défaut `false`.
1279
1281
  * @returns - `true` si l'utilisateur est administrateur, `false` sinon.
1280
1282
  * @throws {ApiError}
1281
1283
  */
1282
- isAdmin(): boolean;
1284
+ isAdmin(options?: {
1285
+ checkHierarchy?: boolean;
1286
+ }): boolean;
1283
1287
  /**
1284
1288
  * Vérifie si l'utilisateur est soit l'auteur, soit administrateur de l'entité.
1285
1289
  *