getUser()->isAdmin() && !$this->getUser()->isRegular()) { throw new Forbidden(); } } public function getActionRead($params, $data, $request) { $id = $params['id'] ?? null; if (!$id) throw new BadRequest(); if (!$this->getUser()->isAdmin() && $id !== $this->getUser()->id) throw new Forbidden(); return $this->getService('UserSecurity')->read($id); } public function postActionGenerate2FAData($params, $data) { $data = $data ?? (object) []; $id = $data->id; if (!$id) throw new BadRequest(); if (!$this->getUser()->isAdmin() && $id !== $this->getUser()->id) throw new Forbidden(); return $this->getService('UserSecurity')->generate2FAData($id, $data); } public function putActionUpdate($params, $data) { $id = $params['id'] ?? null; $data = $data ?? (object) []; if (!$id) throw new BadRequest(); if (!$this->getUser()->isAdmin() && $id !== $this->getUser()->id) throw new Forbidden(); return $this->getService('UserSecurity')->update($id, $data); } }