From 4e4f2e289b0735f3faeb9dc737705c76cfee19b7 Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Thu, 25 Jan 2024 10:40:47 +0000 Subject: [PATCH] add my/permission/checker to business controller --- hesabixCore/composer.lock | 46 +++++++++---------- .../src/Controller/BusinessController.php | 17 ++++++- hesabixCore/src/Service/JsonResp.php | 26 +++++------ 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/hesabixCore/composer.lock b/hesabixCore/composer.lock index 8487228..cb3bbae 100644 --- a/hesabixCore/composer.lock +++ b/hesabixCore/composer.lock @@ -354,16 +354,16 @@ }, { "name": "doctrine/dbal", - "version": "3.7.2", + "version": "3.7.3", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "0ac3c270590e54910715e9a1a044cc368df282b2" + "reference": "ce594cbc39a4866c544f1a970d285ff0548221ad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/0ac3c270590e54910715e9a1a044cc368df282b2", - "reference": "0ac3c270590e54910715e9a1a044cc368df282b2", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/ce594cbc39a4866c544f1a970d285ff0548221ad", + "reference": "ce594cbc39a4866c544f1a970d285ff0548221ad", "shasum": "" }, "require": { @@ -379,14 +379,14 @@ "doctrine/coding-standard": "12.0.0", "fig/log-test": "^1", "jetbrains/phpstorm-stubs": "2023.1", - "phpstan/phpstan": "1.10.42", + "phpstan/phpstan": "1.10.56", "phpstan/phpstan-strict-rules": "^1.5", - "phpunit/phpunit": "9.6.13", + "phpunit/phpunit": "9.6.15", "psalm/plugin-phpunit": "0.18.4", "slevomat/coding-standard": "8.13.1", - "squizlabs/php_codesniffer": "3.7.2", - "symfony/cache": "^5.4|^6.0", - "symfony/console": "^4.4|^5.4|^6.0", + "squizlabs/php_codesniffer": "3.8.1", + "symfony/cache": "^5.4|^6.0|^7.0", + "symfony/console": "^4.4|^5.4|^6.0|^7.0", "vimeo/psalm": "4.30.0" }, "suggest": { @@ -447,7 +447,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.7.2" + "source": "https://github.com/doctrine/dbal/tree/3.7.3" }, "funding": [ { @@ -463,7 +463,7 @@ "type": "tidelift" } ], - "time": "2023-11-19T08:06:58+00:00" + "time": "2024-01-21T07:53:09+00:00" }, { "name": "doctrine/deprecations", @@ -1156,16 +1156,16 @@ }, { "name": "doctrine/orm", - "version": "2.17.2", + "version": "2.17.3", "source": { "type": "git", "url": "https://github.com/doctrine/orm.git", - "reference": "393679a4795e49b0b3ac317dce84d0f8888f2b77" + "reference": "398ab0547aaf90bdb352b560a94c24f44ff00670" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/orm/zipball/393679a4795e49b0b3ac317dce84d0f8888f2b77", - "reference": "393679a4795e49b0b3ac317dce84d0f8888f2b77", + "url": "https://api.github.com/repos/doctrine/orm/zipball/398ab0547aaf90bdb352b560a94c24f44ff00670", + "reference": "398ab0547aaf90bdb352b560a94c24f44ff00670", "shasum": "" }, "require": { @@ -1251,9 +1251,9 @@ ], "support": { "issues": "https://github.com/doctrine/orm/issues", - "source": "https://github.com/doctrine/orm/tree/2.17.2" + "source": "https://github.com/doctrine/orm/tree/2.17.3" }, - "time": "2023-12-20T21:47:52+00:00" + "time": "2024-01-16T21:32:04+00:00" }, { "name": "doctrine/persistence", @@ -9260,16 +9260,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.15", + "version": "9.6.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1" + "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/05017b80304e0eb3f31d90194a563fd53a6021f1", - "reference": "05017b80304e0eb3f31d90194a563fd53a6021f1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3767b2c56ce02d01e3491046f33466a1ae60a37f", + "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f", "shasum": "" }, "require": { @@ -9343,7 +9343,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.15" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.16" }, "funding": [ { @@ -9359,7 +9359,7 @@ "type": "tidelift" } ], - "time": "2023-12-01T16:55:19+00:00" + "time": "2024-01-19T07:03:14+00:00" }, { "name": "sebastian/cli-parser", diff --git a/hesabixCore/src/Controller/BusinessController.php b/hesabixCore/src/Controller/BusinessController.php index 98252e1..59a6a16 100644 --- a/hesabixCore/src/Controller/BusinessController.php +++ b/hesabixCore/src/Controller/BusinessController.php @@ -334,9 +334,22 @@ class BusinessController extends AbstractController return $this->json(['result'=>-1]); } - #[Route('/api/business/get/user/permissions', name: 'api_business_get_user_permission')] - public function api_business_get_user_permission(Log $log,Request $request,EntityManagerInterface $entityManager): Response + #[Route('/api/business/my/permission/state', name: 'api_business_my_permission_state')] + public function api_business_my_permission_state(Request $request,Access $access): Response { + $reqdata = json_decode($request->getContent(), true); + if(!array_key_exists('permission',$reqdata)){ + throw $this->createNotFoundException(); + } + $acc = $access->hasRole($reqdata['permission']); + if($acc) + return $this->json(['state'=>true]); + return $this->json(['state'=>false]); + } + #[Route('/api/business/get/user/permissions', name: 'api_business_get_user_permission')] + public function api_business_get_user_permission(Request $request,EntityManagerInterface $entityManager): Response + { + $params = []; if ($content = $request->getContent()) { $params = json_decode($content, true); diff --git a/hesabixCore/src/Service/JsonResp.php b/hesabixCore/src/Service/JsonResp.php index 5c0a7a3..395b881 100644 --- a/hesabixCore/src/Service/JsonResp.php +++ b/hesabixCore/src/Service/JsonResp.php @@ -12,19 +12,19 @@ class JsonResp // this function get Hesabdari Document in entity format and return back in array format public static function SerializeHesabdariDoc(HesabdariDoc $hesabdariDoc) : array { return [ - 'id' => $hesabdariDoc->getId(), - 'dateSubmit' => $hesabdariDoc->getDateSubmit(), - 'date' => $hesabdariDoc->getDate(), - 'type' => $hesabdariDoc->getType(), - 'code' => $hesabdariDoc->getCode(), - 'des' => $hesabdariDoc->getDes(), - 'amount'=>$hesabdariDoc->getAmount(), - 'mdate' =>$hesabdariDoc->getMdate(), - 'plugin'=>$hesabdariDoc->getPlugin(), - 'refData'=>$hesabdariDoc->getRefData(), - 'shortLink'=>$hesabdariDoc->getShortlink(), - 'status' => $hesabdariDoc->getStatus(), - 'tempStatus' => $hesabdariDoc->getTempStatus(), + 'id' => $hesabdariDoc->getId(), + 'dateSubmit' => $hesabdariDoc->getDateSubmit(), + 'date' => $hesabdariDoc->getDate(), + 'type' => $hesabdariDoc->getType(), + 'code' => $hesabdariDoc->getCode(), + 'des' => $hesabdariDoc->getDes(), + 'amount' => $hesabdariDoc->getAmount(), + 'mdate' => $hesabdariDoc->getMdate(), + 'plugin' => $hesabdariDoc->getPlugin(), + 'refData' => $hesabdariDoc->getRefData(), + 'shortLink' => $hesabdariDoc->getShortlink(), + 'status' => $hesabdariDoc->getStatus(), + 'tempStatus' => $hesabdariDoc->getTempStatus(), ]; } } \ No newline at end of file