Revert changes regarding AccountAPI createAccount
This commit is contained in:
parent
e41de7575c
commit
1e96f8c3d9
2 changed files with 39 additions and 7 deletions
|
@ -56,9 +56,8 @@ App::post('/v1/account')
|
||||||
->label('sdk.response.model', Response::MODEL_ACCOUNT)
|
->label('sdk.response.model', Response::MODEL_ACCOUNT)
|
||||||
->label('abuse-limit', 10)
|
->label('abuse-limit', 10)
|
||||||
->param('userId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
->param('userId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
||||||
->param('email', null, new Email(), 'User email.', true)
|
->param('email', '', new Email(), 'User email.')
|
||||||
->param('password', '', new Password(), 'User password. Must be at least 8 chars.', true)
|
->param('password', '', new Password(), 'User password. Must be at least 8 chars.')
|
||||||
->param('phone', null, new Phone(), 'Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true)
|
|
||||||
->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true)
|
->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true)
|
||||||
->inject('request')
|
->inject('request')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
|
@ -67,7 +66,7 @@ App::post('/v1/account')
|
||||||
->inject('audits')
|
->inject('audits')
|
||||||
->inject('usage')
|
->inject('usage')
|
||||||
->inject('events')
|
->inject('events')
|
||||||
->action(function (string $userId, ?string $email, string $password, ?string $phone, string $name, Request $request, Response $response, Document $project, Database $dbForProject, Audit $audits, Stats $usage, Event $events) {
|
->action(function (string $userId, string $email, string $password, string $name, Request $request, Response $response, Document $project, Database $dbForProject, Audit $audits, Stats $usage, Event $events) {
|
||||||
$email = \strtolower($email);
|
$email = \strtolower($email);
|
||||||
if ('console' === $project->getId()) {
|
if ('console' === $project->getId()) {
|
||||||
$whitelistEmails = $project->getAttribute('authWhitelistEmails');
|
$whitelistEmails = $project->getAttribute('authWhitelistEmails');
|
||||||
|
@ -100,10 +99,8 @@ App::post('/v1/account')
|
||||||
'$write' => ['user:' . $userId],
|
'$write' => ['user:' . $userId],
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'emailVerification' => false,
|
'emailVerification' => false,
|
||||||
'phone' => $phone,
|
|
||||||
'phoneVerification' => false,
|
|
||||||
'status' => true,
|
'status' => true,
|
||||||
'password' => (!empty($password)) ? Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS) : '',
|
'password' => Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS),
|
||||||
'hash' => Auth::DEFAULT_ALGO,
|
'hash' => Auth::DEFAULT_ALGO,
|
||||||
'hashOptions' => Auth::DEFAULT_ALGO_OPTIONS,
|
'hashOptions' => Auth::DEFAULT_ALGO_OPTIONS,
|
||||||
'passwordUpdate' => \time(),
|
'passwordUpdate' => \time(),
|
||||||
|
|
|
@ -51,6 +51,41 @@ trait AccountBase
|
||||||
|
|
||||||
$this->assertEquals($response['headers']['status-code'], 409);
|
$this->assertEquals($response['headers']['status-code'], 409);
|
||||||
|
|
||||||
|
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
|
||||||
|
'origin' => 'http://localhost',
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
]), [
|
||||||
|
'userId' => 'unique()',
|
||||||
|
'email' => '',
|
||||||
|
'password' => '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals($response['headers']['status-code'], 400);
|
||||||
|
|
||||||
|
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
|
||||||
|
'origin' => 'http://localhost',
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
]), [
|
||||||
|
'userId' => 'unique()',
|
||||||
|
'email' => $email,
|
||||||
|
'password' => '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals($response['headers']['status-code'], 400);
|
||||||
|
|
||||||
|
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
|
||||||
|
'origin' => 'http://localhost',
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
]), [
|
||||||
|
'userId' => 'unique()',
|
||||||
|
'email' => '',
|
||||||
|
'password' => $password,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals($response['headers']['status-code'], 400);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
|
|
Loading…
Reference in a new issue