SuperAdminGetController.php 649 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace Controllers;
  3. use Libs\ResponseLib;
  4. use Psr\Http\Message\ServerRequestInterface;
  5. class SuperAdminGetController
  6. {
  7. public function __invoke(ServerRequestInterface $request)
  8. {
  9. $companyId = (int)($request->getAttribute('api_company_id') ?? 0);
  10. if ($companyId <= 0) {
  11. return ResponseLib::sendFail('Authenticated company not found', [], 'E_VALIDATE')->withStatus(401);
  12. }
  13. $isSuperAdmin = ($companyId === 1 || $companyId === 2);
  14. return ResponseLib::sendOk([
  15. 'superadmin' => $isSuperAdmin,
  16. 'company_id' => $companyId,
  17. ], 'S_SUPERADMIN');
  18. }
  19. }