Disallow creating more than 5 account API keys; closes #2123
Additional fixes for https://github.com/pterodactyl/panel/security/advisories/GHSA-pjmh-7xfm-r4x9
This commit is contained in:
parent
7deed07cd1
commit
78514f9eb4
2 changed files with 18 additions and 4 deletions
|
@ -82,10 +82,13 @@ class AccountKeyController extends Controller
|
|||
*/
|
||||
public function store(StoreAccountKeyRequest $request)
|
||||
{
|
||||
if ($this->repository->findCountWhere(['user_id' => $request->user()->id]) >= 5) {
|
||||
throw new DisplayException(
|
||||
'Cannot assign more than 5 API keys to an account.'
|
||||
);
|
||||
$count = $this->repository->findCountWhere([
|
||||
['user_id', '=', $request->user()->id],
|
||||
['key_type', '=', ApiKey::TYPE_ACCOUNT],
|
||||
]);
|
||||
|
||||
if ($count >= 5) {
|
||||
throw new DisplayException('Cannot assign more than 5 API keys to an account.');
|
||||
}
|
||||
|
||||
$this->keyService->setKeyType(ApiKey::TYPE_ACCOUNT)->handle([
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue