mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 08:58:35 +00:00
fix: string encryption attribute in model.
This commit is contained in:
parent
9334b98308
commit
d6b55730eb
2 changed files with 17 additions and 1 deletions
|
|
@ -72,6 +72,7 @@ class Create extends Action
|
|||
->inject('dbForProject')
|
||||
->inject('queueForDatabase')
|
||||
->inject('queueForEvents')
|
||||
->inject('plan')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
|
|
@ -87,8 +88,20 @@ class Create extends Action
|
|||
UtopiaResponse $response,
|
||||
Database $dbForProject,
|
||||
EventDatabase $queueForDatabase,
|
||||
Event $queueForEvents
|
||||
Event $queueForEvents,
|
||||
array $plan
|
||||
): void {
|
||||
if ($encrypt && !empty($plan) && !($plan['databasesAllowEncrypt'] ?? false)) {
|
||||
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Encrypted string ' . $this->getSdkGroup() . ' are not available on your plan. Please upgrade to create encrypted string ' . $this->getSdkGroup() . '.');
|
||||
}
|
||||
|
||||
if ($encrypt && $size < APP_DATABASE_ENCRYPT_SIZE_MIN) {
|
||||
throw new Exception(
|
||||
Exception::GENERAL_BAD_REQUEST,
|
||||
"Size too small. Encrypted strings require a minimum size of " . APP_DATABASE_ENCRYPT_SIZE_MIN . " characters."
|
||||
);
|
||||
}
|
||||
|
||||
// Ensure default fits in the given size
|
||||
$validator = new Text($size, 0);
|
||||
if (!is_null($default) && !$validator->isValid($default)) {
|
||||
|
|
@ -118,6 +131,8 @@ class Create extends Action
|
|||
$queueForEvents
|
||||
);
|
||||
|
||||
$attribute->setAttribute('encrypt', $encrypt);
|
||||
|
||||
$response
|
||||
->setStatusCode(SwooleResponse::STATUS_CODE_ACCEPTED)
|
||||
->dynamic($attribute, $this->getResponseModel());
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ class Create extends StringCreate
|
|||
->inject('dbForProject')
|
||||
->inject('queueForDatabase')
|
||||
->inject('queueForEvents')
|
||||
->inject('plan')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue