custom id support in create user
This commit is contained in:
parent
0152e3b69c
commit
5e2f3ed9c9
1 changed files with 4 additions and 2 deletions
|
@ -17,6 +17,7 @@ use Utopia\Database\Document;
|
|||
use Utopia\Database\Exception\Duplicate;
|
||||
use Utopia\Database\Validator\UID;
|
||||
use DeviceDetector\DeviceDetector;
|
||||
use Utopia\Database\Validator\Key;
|
||||
|
||||
App::post('/v1/users')
|
||||
->desc('Create User')
|
||||
|
@ -30,19 +31,20 @@ App::post('/v1/users')
|
|||
->label('sdk.response.code', Response::STATUS_CODE_CREATED)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_USER)
|
||||
->param('id', 'uid()', new Key(), 'Unique Id. Passing `uid()` will auto generate the id.')
|
||||
->param('email', '', new Email(), 'User email.')
|
||||
->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.')
|
||||
->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true)
|
||||
->inject('response')
|
||||
->inject('dbForInternal')
|
||||
->action(function ($email, $password, $name, $response, $dbForInternal) {
|
||||
->action(function ($id, $email, $password, $name, $response, $dbForInternal) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Database\Database $dbForInternal */
|
||||
|
||||
$email = \strtolower($email);
|
||||
|
||||
try {
|
||||
$userId = $dbForInternal->getId();
|
||||
$userId = $id == 'uid()' ? $dbForInternal->getId() : $id;
|
||||
$user = $dbForInternal->createDocument('users', new Document([
|
||||
'$id' => $userId,
|
||||
'$read' => ['role:all'],
|
||||
|
|
Loading…
Reference in a new issue