diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteSignature.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteSignature.php index 176163c..3004801 100644 --- a/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteSignature.php +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsDeleteSignature.php @@ -23,28 +23,21 @@ */ public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface { - if(!$rpcRequest->containsParameter('uuid')) + if(!$rpcRequest->containsParameter('signature_uuid')) { - throw new MissingRpcArgumentException('uuid'); + throw new MissingRpcArgumentException('signature_uuid'); } + $signatureUuid = (string)$rpcRequest->getParameter('signature_uuid'); + try { - $uuid = Uuid::fromString($rpcRequest->getParameter('uuid')); - } - catch(InvalidArgumentException) - { - throw new InvalidRpcArgumentException('uuid'); - } - - try - { - if(!SigningKeysManager::signingKeyExists($request->getPeer()->getUuid(), $uuid)) + if(!SigningKeysManager::signingKeyExists($request->getPeer()->getUuid(), $signatureUuid)) { return $rpcRequest->produceResponse(false); } - SigningKeysManager::deleteSigningKey($request->getPeer()->getUuid(), $uuid); + SigningKeysManager::deleteSigningKey($request->getPeer()->getUuid(), $signatureUuid); } catch(DatabaseOperationException $e) { diff --git a/src/Socialbox/Managers/SigningKeysManager.php b/src/Socialbox/Managers/SigningKeysManager.php index 15cf4bc..0c4eb75 100644 --- a/src/Socialbox/Managers/SigningKeysManager.php +++ b/src/Socialbox/Managers/SigningKeysManager.php @@ -235,16 +235,26 @@ * Deletes a signing key from the database using the provided UUID. * * @param string $peerUuid The UUID of the peer associated with the signing key. - * @param string $uuid The UUID of the signing key to delete. + * @param string $signatureUuid The UUID of the signing key to delete. * @return void * @throws DatabaseOperationException If a database error occurs during the operation. */ - public static function deleteSigningKey(string $peerUuid, string $uuid): void + public static function deleteSigningKey(string $peerUuid, string $signatureUuid): void { + if(!Validator::validateUuid($peerUuid)) + { + throw new InvalidArgumentException('The given internal peer UUID is not a valid UUID V4'); + } + + if(!Validator::validateUuid($signatureUuid)) + { + throw new InvalidArgumentException('The given signature UUID is not a valid UUID V4'); + } + try { $statement = Database::getConnection()->prepare("DELETE FROM signing_keys WHERE uuid=:uuid AND peer_uuid=:peer_uuid"); - $statement->bindParam(':uuid', $uuid); + $statement->bindParam(':uuid', $signatureUuid); $statement->bindParam(':peer_uuid', $peerUuid); $statement->execute(); }