mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
misc: updates, cleanups.
This commit is contained in:
@@ -446,10 +446,11 @@
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (!password || !password.value.trim()) {
|
||||
const passwordValue = password?.value ?? '';
|
||||
if (!password || !/\S/.test(passwordValue)) {
|
||||
setFieldError?.(password, 'Please enter a password');
|
||||
valid = false;
|
||||
} else if (!isValidPassword?.(password.value.trim())) {
|
||||
} else if (!isValidPassword?.(passwordValue)) {
|
||||
setFieldError?.(password, 'Password must be at least 8 characters');
|
||||
valid = false;
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ class HttpHandler
|
||||
$input['emailCertificates'] = $emailCertificates;
|
||||
|
||||
$opensslKey = trim((string) ($input['opensslKey'] ?? ''));
|
||||
if ($opensslKey === '' || strlen($opensslKey) > 64) {
|
||||
if (!$this->state->isValidSecretKey($opensslKey)) {
|
||||
$this->respondBadRequest('Secret API key must be 1-64 characters', $wantsStream);
|
||||
}
|
||||
$input['opensslKey'] = $opensslKey;
|
||||
@@ -308,7 +308,7 @@ class HttpHandler
|
||||
|
||||
if (!$this->config->isUpgrade()) {
|
||||
$accountName = trim((string) ($input['accountName'] ?? ''));
|
||||
if ($accountName === '') {
|
||||
if (!$this->state->isValidAccountName($accountName)) {
|
||||
$this->respondBadRequest('Please enter a name', $wantsStream, Server::STEP_ACCOUNT_SETUP);
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ class HttpHandler
|
||||
}
|
||||
|
||||
$accountPassword = (string) ($input['accountPassword'] ?? '');
|
||||
if (!preg_match('/\\S/', $accountPassword) || !$this->state->isValidPassword($accountPassword)) {
|
||||
if (!$this->state->isValidPassword($accountPassword)) {
|
||||
$this->respondBadRequest('Password must be at least 8 characters', $wantsStream, Server::STEP_ACCOUNT_SETUP);
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,16 @@ class State
|
||||
return strlen($value) >= 8 && preg_match('/\S/', $value) === 1;
|
||||
}
|
||||
|
||||
public function isValidSecretKey(string $value): bool
|
||||
{
|
||||
return $value !== '' && strlen($value) <= 64;
|
||||
}
|
||||
|
||||
public function isValidAccountName(string $value): bool
|
||||
{
|
||||
return trim($value) !== '';
|
||||
}
|
||||
|
||||
public function isValidAppDomainInput(string $value): bool
|
||||
{
|
||||
$value = trim($value);
|
||||
|
||||
Reference in New Issue
Block a user