Browse Source

set security on dolibarr account apiresource

Olivier Massot 4 years ago
parent
commit
c3ff33fe12
1 changed files with 5 additions and 16 deletions
  1. 5 16
      src/ApiResources/Dolibarr/DolibarrAccount.php

+ 5 - 16
src/ApiResources/Dolibarr/DolibarrAccount.php

@@ -14,6 +14,11 @@ use Symfony\Component\Serializer\Annotation\Groups;
 #[ApiResource(
     itemOperations: [
         'get' => [
+            'security' => '(is_granted("ROLE_ADMIN_CORE") or 
+                            is_granted("ROLE_ADMINISTRATIF_MANAGER_CORE") or 
+                            is_granted("ROLE_PEDAGOGICS_MANAGER_CORE") or 
+                            is_granted("ROLE_FINANCIAL_MANAGER_CORE")
+                           ) and object.getOrganizationId() == user.getOrganization().getId()',
             'method' => 'GET',
             'path' => '/dolibarr/account/{organizationId}',
             'requirements' => ['organizationId' => '\d+'],
@@ -54,12 +59,6 @@ class DolibarrAccount
     #[Groups('dolibarr_get')]
     private ?object $contract = null;
 
-    /**
-     * Sms credit remaining
-     */
-    #[Groups('dolibarr_get')]
-    private string $smsCredit = "";
-
     /**
      * Last bills
      */
@@ -116,16 +115,6 @@ class DolibarrAccount
         $this->contract = $contract;
     }
 
-    public function getSmsCredit(): string
-    {
-        return $this->smsCredit;
-    }
-
-    public function setSmsCredit(string $smsCredit): void
-    {
-        $this->smsCredit = $smsCredit;
-    }
-
     public function getBills(): array
     {
         return $this->bills;