Files
casadoc/public/userportal/api/share-delete.php
T
2026-07-27 21:04:07 +03:00

33 lines
903 B
PHP

<?php
require __DIR__ . '/_bootstrap.php';
/**
* @OA\Post(
* path="/share-delete.php",
* tags={"Sharing"},
* summary="Delete a sharing condition",
* security={{"bearerAuth":{}}},
* @OA\RequestBody(required=true, @OA\JsonContent(
* required={"idsharing"},
* @OA\Property(property="idsharing", type="integer")
* )),
* @OA\Response(response=200, ref="#/components/responses/Success"),
* @OA\Response(response=403, ref="#/components/responses/Forbidden")
* )
*/
require_method('POST');
$user = require_auth($pdo);
$idsharing = (int) (body()['idsharing'] ?? 0);
if ($idsharing <= 0) {
json_error(422, 'idsharing is required');
}
if (!user_owns_share($pdo, $user, $idsharing)) {
json_error(403, 'No access to this share');
}
$pdo->prepare('DELETE FROM home_sharing WHERE idsharing = ? AND iduser = ?')
->execute([$idsharing, $user['id']]);
json_ok();