Skip to content

Commit fb7ebc0

Browse files
committed
add condition for user and circle existance
Signed-off-by: samin-z <samin.zavarkesh@gmail.com>
1 parent 6af1d60 commit fb7ebc0

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/Service/ColumnTypes/UsergroupBusiness.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
use OCA\Tables\Db\Column;
1212
use OCA\Tables\Errors\BadRequestError;
1313
use OCA\Tables\Helper\CircleHelper;
14+
use OCP\IUserManager;
1415
use Psr\Log\LoggerInterface;
1516

1617
class UsergroupBusiness extends SuperBusiness {
1718

1819
public function __construct(
1920
protected LoggerInterface $logger,
2021
protected CircleHelper $circleHelper,
22+
protected IUserManager $userManager,
2123
) {
2224
parent::__construct($logger);
2325
}
@@ -52,6 +54,12 @@ public function validateValue(mixed $value, Column $column, string $userId, int
5254
throw new BadRequestError('Invalid usergroup type');
5355
}
5456
if ($userGroupEntry['type'] === UsergroupType::CIRCLE) {
57+
if ($this->userManager->get($userId) === null) {
58+
throw new BadRequestError('User not found');
59+
}
60+
if (!$this->circleHelper->circleExists($userGroupEntry['id'], null)) {
61+
throw new BadRequestError('Circle does not exist');
62+
}
5563
if (!$this->circleHelper->circleExists($userGroupEntry['id'], $userId)) {
5664
throw new BadRequestError('Circle not found');
5765
}

0 commit comments

Comments
 (0)