Skip to content

Commit ddd884f

Browse files
committed
check value type for type constant
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
1 parent 136452d commit ddd884f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

lib/Service/ColumnTypes/UsergroupBusiness.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace OCA\Tables\Service\ColumnTypes;
99

10+
use OCA\Tables\Constants\UsergroupType;
1011
use OCA\Tables\Db\Column;
1112
use OCA\Tables\Errors\BadRequestError;
1213
use OCA\Tables\Helper\CircleHelper;
@@ -47,9 +48,13 @@ public function validateValue(mixed $value, Column $column, string $userId, int
4748
if (!isset($circleEntry['id']) || !is_string($circleEntry['id'])) {
4849
throw new BadRequestError('Invalid circle id');
4950
}
50-
51-
if (!$this->circleHelper->circleExists($circleEntry['id'], $userId)) {
52-
throw new BadRequestError("User does not belong to circle: {$circleEntry['displayName']}");
51+
if (!isset($circleEntry['type']) || !is_int($circleEntry['type'])) {
52+
throw new BadRequestError('Invalid usergroup type');
53+
}
54+
if ($circleEntry['type'] === UsergroupType::CIRCLE) {
55+
if (!$this->circleHelper->circleExists($circleEntry['id'], $userId)) {
56+
throw new BadRequestError("User does not belong to circle: {$circleEntry['displayName']}");
57+
}
5358
}
5459
}
5560
}

0 commit comments

Comments
 (0)