public function run() { $appPrm = $this->request->getData()['AppPermission']; $apiKey = $appPrm['apiKey']; $res = $this->forward('/apps/validate/' . $apiKey); $appId = $res->getData()['App']['id']; $permission = new AppPermission(); $permission->setAppId($appId); $permission->setAction($appPrm['action']); if ($permission->read() === null) { $this->sendModel($permission->create()); } else { throw new GraphException('permission already assigned'); } }
public function run() { $apiKey = $this->request->getPar('apiKey'); $res = $this->forward('/apps/validate/' . $apiKey); if ($res->getStatusCode() !== 200) { throw new GraphException('Application not found'); } $app = json_decode($res->getBody(), true)['App']; $appPerm = new AppPermission(); $appPerm->setAppId($app['id']); $rdd = $appPerm->read(true); $ret = []; foreach ($rdd as $appPermission) { $ret[] = $appPermission->getAction(); } $this->response->setBody(json_encode(["AppPermissions" => $ret])); }
public function run() { $appPrm = json_decode($this->request->getBody(), true)['AppPermission']; $apiKey = $appPrm['apiKey']; $res = $this->forward('/apps/validate/' . $apiKey); if ($res->getStatusCode() !== 200) { throw new GraphException('Application not found', 400); } $appId = json_decode($res->getBody(), true)['App']['id']; $permission = new AppPermission(); $permission->setAppId($appId); $permission->setAction($appPrm['action']); $rPermission = $permission->read(); if ($rPermission !== null) { $rPermission->delete(); $this->sendMessage('permission deleted successfully'); } else { throw new GraphException('permission not found'); } }