Forráskód Böngészése

handle admin be_user update case

Olivier Massot 11 hónapja
szülő
commit
3ae4fa45db
1 módosított fájl, 13 hozzáadás és 2 törlés
  1. 13 2
      ot_connect/Classes/Service/OtAuthenticationService.php

+ 13 - 2
ot_connect/Classes/Service/OtAuthenticationService.php

@@ -31,6 +31,8 @@ class OtAuthenticationService extends AbstractAuthenticationService
     CONST ISAUTH_URI = 'api/user/isauthenticated';
     CONST LOGOUT_URI = 'logout';
     CONST GROUP_FE_ALL_UID = 18076;
+    CONST GROUP_ADMIN_STANDARD_UID = 1;
+    CONST GROUP_ADMIN_PREMIUM_UID = 3;
 
     // Cookies' domain needs to be the same that the api's cookies, or guzzle will ignore them.
     CONST COOKIE_DOMAIN = 'opentalent.fr';
@@ -368,13 +370,22 @@ class OtAuthenticationService extends AbstractAuthenticationService
         // Loop over the accesses of the user to list the matching organization groups
         if ($userApiData['accesses']) {
             foreach ($userApiData['accesses'] as $accessData) {
-                if ($isBackend && !$accessData['isEditor']) {
+                if ($isBackend && !$accessData['isEditor'] && !$accessData['admin_access']) {
                     continue;
                 }
 
+                if ($isBackend && $accessData['admin_access']) {
+                    $adminGroupUid = $accessData['product'] === 'artist_premium' ?
+                        self::GROUP_ADMIN_PREMIUM_UID :
+                        self::GROUP_ADMIN_STANDARD_UID;
+                    if (!in_array($adminGroupUid, $groupsUid)) {
+                        $groupsUid[] = $adminGroupUid;
+                    }
+                }
+
                 $organizationId = $accessData['organizationId'];
 
-                // get the fe_group for this organization
+                // get the group for this organization
                 $groupUid = $connection->fetchOne(
                     "select g.uid
                      from typo3.$group_table g