Model changes
This commit is contained in:
parent
af518cf1f4
commit
8628105eef
32 changed files with 199 additions and 5575 deletions
|
@ -825,7 +825,7 @@ $collections = [
|
|||
],
|
||||
[
|
||||
'$id' => 'updated',
|
||||
'type' => Database::VAR_INTEGER,
|
||||
'type' => Database::VAR_DATETIME, // ok!
|
||||
'format' => '',
|
||||
'size' => 0,
|
||||
'signed' => true,
|
||||
|
@ -1162,7 +1162,7 @@ $collections = [
|
|||
],
|
||||
[
|
||||
'$id' => 'passwordUpdate',
|
||||
'type' => Database::VAR_INTEGER,
|
||||
'type' => Database::VAR_DATETIME,
|
||||
'format' => '',
|
||||
'size' => 0,
|
||||
'signed' => true,
|
||||
|
@ -1184,7 +1184,7 @@ $collections = [
|
|||
],
|
||||
[
|
||||
'$id' => 'registration',
|
||||
'type' => Database::VAR_INTEGER,
|
||||
'type' => Database::VAR_DATETIME,
|
||||
'format' => '',
|
||||
'size' => 0,
|
||||
'signed' => true,
|
||||
|
@ -2459,7 +2459,7 @@ $collections = [
|
|||
],
|
||||
[
|
||||
'$id' => 'issueDate',
|
||||
'type' => Database::VAR_INTEGER,
|
||||
'type' => Database::VAR_DATETIME, // ok!
|
||||
'format' => '',
|
||||
'size' => 0,
|
||||
'signed' => true,
|
||||
|
@ -2470,7 +2470,7 @@ $collections = [
|
|||
],
|
||||
[
|
||||
'$id' => 'renewDate',
|
||||
'type' => Database::VAR_INTEGER,
|
||||
'type' => Database::VAR_INTEGER, // cert.pem is time stamp?
|
||||
'format' => '',
|
||||
'size' => 0,
|
||||
'signed' => true,
|
||||
|
@ -2503,7 +2503,7 @@ $collections = [
|
|||
],
|
||||
[
|
||||
'$id' => 'updated',
|
||||
'type' => Database::VAR_INTEGER,
|
||||
'type' => Database::VAR_DATETIME,
|
||||
'format' => '',
|
||||
'size' => 0,
|
||||
'signed' => true,
|
||||
|
|
|
@ -102,8 +102,8 @@ App::post('/v1/account')
|
|||
'emailVerification' => false,
|
||||
'status' => true,
|
||||
'password' => Auth::passwordHash($password),
|
||||
'passwordUpdate' => \time(),
|
||||
'registration' => \time(),
|
||||
'passwordUpdate' => Database::getCurrentDateTime(),
|
||||
'registration' => Database::getCurrentDateTime(),
|
||||
'reset' => false,
|
||||
'name' => $name,
|
||||
'prefs' => new \stdClass(),
|
||||
|
@ -483,8 +483,8 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
|||
'emailVerification' => true,
|
||||
'status' => true, // Email should already be authenticated by OAuth2 provider
|
||||
'password' => Auth::passwordHash(Auth::passwordGenerator()),
|
||||
'passwordUpdate' => 0,
|
||||
'registration' => \time(),
|
||||
'passwordUpdate' => null,
|
||||
'registration' => Database::getCurrentDateTime(),
|
||||
'reset' => false,
|
||||
'name' => $name,
|
||||
'prefs' => new \stdClass(),
|
||||
|
@ -648,8 +648,8 @@ App::post('/v1/account/sessions/magic-url')
|
|||
'emailVerification' => false,
|
||||
'status' => true,
|
||||
'password' => null,
|
||||
'passwordUpdate' => 0,
|
||||
'registration' => \time(),
|
||||
'passwordUpdate' => null,
|
||||
'registration' => Database::getCurrentDateTime(),
|
||||
'reset' => false,
|
||||
'prefs' => new \stdClass(),
|
||||
'sessions' => null,
|
||||
|
@ -891,8 +891,8 @@ App::post('/v1/account/sessions/phone')
|
|||
'phoneVerification' => false,
|
||||
'status' => true,
|
||||
'password' => null,
|
||||
'passwordUpdate' => 0,
|
||||
'registration' => \time(),
|
||||
'passwordUpdate' => null,
|
||||
'registration' => Database::getCurrentDateTime(),
|
||||
'reset' => false,
|
||||
'prefs' => new \stdClass(),
|
||||
'sessions' => null,
|
||||
|
@ -1117,8 +1117,8 @@ App::post('/v1/account/sessions/anonymous')
|
|||
'emailVerification' => false,
|
||||
'status' => true,
|
||||
'password' => null,
|
||||
'passwordUpdate' => 0,
|
||||
'registration' => \time(),
|
||||
'passwordUpdate' => null,
|
||||
'registration' => Database::getCurrentDateTime(),
|
||||
'reset' => false,
|
||||
'name' => null,
|
||||
'prefs' => new \stdClass(),
|
||||
|
@ -1252,10 +1252,11 @@ App::get('/v1/account')
|
|||
->inject('user')
|
||||
->inject('usage')
|
||||
->action(function (Response $response, Document $user, Stats $usage) {
|
||||
|
||||
var_dump("********** 1 ");
|
||||
$usage->setParam('users.read', 1);
|
||||
|
||||
var_dump("********** 2 ");
|
||||
$response->dynamic($user, Response::MODEL_USER);
|
||||
var_dump("********** 3 ");
|
||||
});
|
||||
|
||||
App::get('/v1/account/prefs')
|
||||
|
@ -1478,7 +1479,7 @@ App::patch('/v1/account/password')
|
|||
->action(function (string $password, string $oldPassword, Response $response, Document $user, Database $dbForProject, Audit $audits, Stats $usage, Event $events) {
|
||||
|
||||
// Check old password only if its an existing user.
|
||||
if ($user->getAttribute('passwordUpdate') !== 0 && !Auth::passwordVerify($oldPassword, $user->getAttribute('password'))) { // Double check user password
|
||||
if ($user->getAttribute('passwordUpdate') !== null && !Auth::passwordVerify($oldPassword, $user->getAttribute('password'))) { // Double check user password
|
||||
throw new Exception('Invalid credentials', 401, Exception::USER_INVALID_CREDENTIALS);
|
||||
}
|
||||
|
||||
|
@ -1487,7 +1488,7 @@ App::patch('/v1/account/password')
|
|||
$user->getId(),
|
||||
$user
|
||||
->setAttribute('password', Auth::passwordHash($password))
|
||||
->setAttribute('passwordUpdate', \time())
|
||||
->setAttribute('passwordUpdate', Database::getCurrentDateTime())
|
||||
);
|
||||
|
||||
$audits
|
||||
|
@ -2062,7 +2063,7 @@ App::put('/v1/account/recovery')
|
|||
|
||||
$profile = $dbForProject->updateDocument('users', $profile->getId(), $profile
|
||||
->setAttribute('password', Auth::passwordHash($password))
|
||||
->setAttribute('passwordUpdate', \time())
|
||||
->setAttribute('passwordUpdate', Database::getCurrentDateTime())
|
||||
->setAttribute('emailVerification', true));
|
||||
|
||||
$recoveryDocument = $dbForProject->getDocument('tokens', $recovery);
|
||||
|
|
|
@ -1244,7 +1244,7 @@ App::post('/v1/projects/:projectId/domains')
|
|||
'$write' => ['role:all'],
|
||||
'projectInternalId' => $project->getInternalId(),
|
||||
'projectId' => $project->getId(),
|
||||
'updated' => \time(),
|
||||
'updated' => Database::getCurrentDateTime(),
|
||||
'domain' => $domain->get(),
|
||||
'tld' => $domain->getSuffix(),
|
||||
'registerable' => $domain->getRegisterable(),
|
||||
|
|
|
@ -339,8 +339,8 @@ App::post('/v1/teams/:teamId/memberships')
|
|||
* team invite and OAuth to allow password updates without an
|
||||
* old password
|
||||
*/
|
||||
'passwordUpdate' => 0,
|
||||
'registration' => \time(),
|
||||
'passwordUpdate' => null,
|
||||
'registration' => Database::getCurrentDateTime(),
|
||||
'reset' => false,
|
||||
'name' => $name,
|
||||
'prefs' => new \stdClass(),
|
||||
|
|
|
@ -63,8 +63,8 @@ App::post('/v1/users')
|
|||
'emailVerification' => false,
|
||||
'status' => true,
|
||||
'password' => Auth::passwordHash($password),
|
||||
'passwordUpdate' => \time(),
|
||||
'registration' => \time(),
|
||||
'passwordUpdate' => Database::getCurrentDateTime(),
|
||||
'registration' => Database::getCurrentDateTime(),
|
||||
'reset' => false,
|
||||
'name' => $name,
|
||||
'prefs' => new \stdClass(),
|
||||
|
@ -550,7 +550,7 @@ App::patch('/v1/users/:userId/password')
|
|||
|
||||
$user
|
||||
->setAttribute('password', Auth::passwordHash($password))
|
||||
->setAttribute('passwordUpdate', \time());
|
||||
->setAttribute('passwordUpdate', Database::getCurrentDateTime());
|
||||
|
||||
$user = $dbForProject->updateDocument('users', $user->getId(), $user);
|
||||
|
||||
|
|
|
@ -311,6 +311,8 @@ App::init(function (App $utopia, Request $request, Response $response, Document
|
|||
}
|
||||
}
|
||||
|
||||
var_dump($scope, $scopes);
|
||||
|
||||
if (!\in_array($scope, $scopes)) {
|
||||
if ($project->isEmpty()) { // Check if permission is denied because project is missing
|
||||
throw new AppwriteException('Project not found', 404, AppwriteException::PROJECT_NOT_FOUND);
|
||||
|
|
|
@ -116,7 +116,7 @@ class CertificatesV1 extends Worker
|
|||
// Update certificate info stored in database
|
||||
$certificate->setAttribute('renewDate', $this->getRenewDate($domain->get()));
|
||||
$certificate->setAttribute('attempts', 0);
|
||||
$certificate->setAttribute('issueDate', \time());
|
||||
$certificate->setAttribute('issueDate', Database::getCurrentDateTime());
|
||||
} catch (Throwable $e) {
|
||||
// Set exception as log in certificate document
|
||||
$certificate->setAttribute('log', $e->getMessage());
|
||||
|
@ -129,7 +129,7 @@ class CertificatesV1 extends Worker
|
|||
$this->notifyError($domain->get(), $e->getMessage(), $attempts);
|
||||
} finally {
|
||||
// All actions result in new updatedAt date
|
||||
$certificate->setAttribute('updated', \time());
|
||||
$certificate->setAttribute('updated', Database::getCurrentDateTime());
|
||||
|
||||
// Save all changes we made to certificate document into database
|
||||
$this->saveCertificateDocument($domain->get(), $certificate);
|
||||
|
@ -399,7 +399,7 @@ class CertificatesV1 extends Worker
|
|||
], 1000);
|
||||
|
||||
foreach ($domains as $domainDocument) {
|
||||
$domainDocument->setAttribute('updated', \time());
|
||||
$domainDocument->setAttribute('updated', Database::getCurrentDateTime());
|
||||
$domainDocument->setAttribute('certificateId', $certificateId);
|
||||
|
||||
$this->dbForConsole->updateDocument('domains', $domainDocument->getId(), $domainDocument);
|
||||
|
|
5383
composer.lock
generated
5383
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -11,6 +11,7 @@ abstract class Model
|
|||
public const TYPE_FLOAT = 'double';
|
||||
public const TYPE_BOOLEAN = 'boolean';
|
||||
public const TYPE_JSON = 'json';
|
||||
public const TYPE_DATETIME = 'datetime';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
|
|
|
@ -17,16 +17,16 @@ class Bucket extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Bucket creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Bucket update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$read', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -17,16 +17,16 @@ class Collection extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Collection creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Collection update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$read', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -17,16 +17,16 @@ class Deployment extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Deployment creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Deployment update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('resourceId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -43,16 +43,16 @@ class Document extends Any
|
|||
'example' => '5e5ea5c15117e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Document creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Document update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$read', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -22,16 +22,16 @@ class Domain extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Domain creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Domain update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('domain', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -17,16 +17,16 @@ class Execution extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Execution creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Execution update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' upate date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$read', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -23,16 +23,16 @@ class File extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'File creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'File update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$read', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -19,16 +19,16 @@ class Func extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Function creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => 'Function creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Function update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => 'Function update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('execute', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -22,16 +22,16 @@ class Key extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Key creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Key update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -17,16 +17,16 @@ class Membership extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Membership creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Membership update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('userId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -22,16 +22,16 @@ class Platform extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Project creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Project update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -24,16 +24,16 @@ class Project extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Project creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Project update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -17,10 +17,10 @@ class Session extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Session creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('userId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -17,16 +17,16 @@ class Team extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Team creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Team update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -17,10 +17,10 @@ class Token extends Model
|
|||
'example' => 'bb8ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Token creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('userId', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -18,16 +18,16 @@ class User extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'User creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'User update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime.',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
@ -36,10 +36,10 @@ class User extends Model
|
|||
'example' => 'John Doe',
|
||||
])
|
||||
->addRule('registration', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'User registration date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => 'User registration date in Datetime.',
|
||||
'default' => null,
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('status', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
|
@ -48,10 +48,10 @@ class User extends Model
|
|||
'example' => true,
|
||||
])
|
||||
->addRule('passwordUpdate', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Unix timestamp of the most recent password update',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => 'Datetime of the most recent password update',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('email', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -22,16 +22,16 @@ class Webhook extends Model
|
|||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('$createdAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Webhook creation date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' creation date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('$updatedAt', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Webhook update date in Unix timestamp.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'type' => self::TYPE_DATETIME,
|
||||
'description' => get_class() . ' update date in Datetime',
|
||||
'default' => '',
|
||||
'example' => '1975-06-12 13:30:59',
|
||||
])
|
||||
->addRule('name', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
|
|
@ -31,7 +31,7 @@ trait AccountBase
|
|||
$this->assertEquals($response['headers']['status-code'], 201);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $email);
|
||||
$this->assertEquals($response['body']['name'], $name);
|
||||
|
||||
|
@ -184,7 +184,7 @@ trait AccountBase
|
|||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $email);
|
||||
$this->assertEquals($response['body']['name'], $name);
|
||||
|
||||
|
@ -463,7 +463,7 @@ trait AccountBase
|
|||
$this->assertIsArray($response['body']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $email);
|
||||
$this->assertEquals($response['body']['name'], $newName);
|
||||
|
||||
|
@ -529,7 +529,7 @@ trait AccountBase
|
|||
$this->assertIsArray($response['body']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $email);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
|
||||
|
@ -619,7 +619,7 @@ trait AccountBase
|
|||
$this->assertIsArray($response['body']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $newEmail);
|
||||
|
||||
/**
|
||||
|
@ -661,7 +661,7 @@ trait AccountBase
|
|||
$this->assertEquals($response['headers']['status-code'], 201);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $data['email']);
|
||||
$this->assertEquals($response['body']['name'], $data['name']);
|
||||
|
||||
|
@ -1356,6 +1356,9 @@ trait AccountBase
|
|||
$sessionId = $response['body']['$id'];
|
||||
$session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
|
||||
|
||||
var_dump($sessionId);
|
||||
var_dump($session);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
|
@ -1366,7 +1369,7 @@ trait AccountBase
|
|||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $email);
|
||||
$this->assertTrue($response['body']['emailVerification']);
|
||||
|
||||
|
@ -1426,7 +1429,7 @@ trait AccountBase
|
|||
$this->assertIsArray($response['body']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $email);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
|
||||
|
|
|
@ -446,7 +446,7 @@ class AccountCustomClientTest extends Scope
|
|||
$this->assertIsArray($response['body']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $email);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
|
||||
|
@ -784,7 +784,7 @@ class AccountCustomClientTest extends Scope
|
|||
$this->assertEquals($response['headers']['status-code'], 200);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['phone'], $number);
|
||||
$this->assertTrue($response['body']['phoneVerification']);
|
||||
|
||||
|
@ -835,7 +835,7 @@ class AccountCustomClientTest extends Scope
|
|||
$this->assertIsArray($response['body']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $email);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
|
||||
|
@ -877,7 +877,7 @@ class AccountCustomClientTest extends Scope
|
|||
$this->assertIsArray($response['body']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['phone'], $newPhone);
|
||||
|
||||
/**
|
||||
|
|
|
@ -267,7 +267,7 @@ trait TeamsBaseClient
|
|||
$this->assertIsArray($response['body']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $email);
|
||||
$this->assertEquals($response['body']['name'], $name);
|
||||
|
||||
|
@ -301,7 +301,7 @@ trait TeamsBaseClient
|
|||
$this->assertIsArray($response['body']);
|
||||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertIsNumeric($response['body']['registration']);
|
||||
$this->assertIsString($response['body']['registration']);
|
||||
$this->assertEquals($response['body']['email'], $email);
|
||||
$this->assertEquals($response['body']['name'], $name);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ trait UsersBase
|
|||
$this->assertEquals($body['name'], 'Cristiano Ronaldo');
|
||||
$this->assertEquals($body['email'], 'cristiano.ronaldo@manchester-united.co.uk');
|
||||
$this->assertEquals($body['status'], true);
|
||||
$this->assertGreaterThan(0, $body['registration']);
|
||||
$this->assertGreaterThan('2000-01-01 00:00:00', $body['registration']);
|
||||
|
||||
/**
|
||||
* Test Create with Custom ID for SUCCESS
|
||||
|
@ -53,7 +53,7 @@ trait UsersBase
|
|||
$this->assertEquals($res['body']['name'], 'Lionel Messi');
|
||||
$this->assertEquals($res['body']['email'], 'lionel.messi@psg.fr');
|
||||
$this->assertEquals(true, $res['body']['status']);
|
||||
$this->assertGreaterThan(0, $res['body']['registration']);
|
||||
$this->assertGreaterThan('2000-01-01 00:00:00', $res['body']['registration']);
|
||||
|
||||
return ['userId' => $body['$id']];
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ trait UsersBase
|
|||
$this->assertEquals($user['body']['name'], 'Cristiano Ronaldo');
|
||||
$this->assertEquals($user['body']['email'], 'cristiano.ronaldo@manchester-united.co.uk');
|
||||
$this->assertEquals($user['body']['status'], true);
|
||||
$this->assertGreaterThan(0, $user['body']['registration']);
|
||||
$this->assertGreaterThan('2000-01-01 00:00:00', $user['body']['registration']);
|
||||
|
||||
$sessions = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/sessions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
|
|
|
@ -57,7 +57,7 @@ class WebhooksCustomClientTest extends Scope
|
|||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id']), true);
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertEquals($webhook['data']['name'], $name);
|
||||
$this->assertIsInt($webhook['data']['registration']);
|
||||
$this->assertIsString($webhook['data']['registration']);
|
||||
$this->assertEquals($webhook['data']['status'], true);
|
||||
$this->assertEquals($webhook['data']['email'], $email);
|
||||
$this->assertEquals($webhook['data']['emailVerification'], false);
|
||||
|
@ -133,7 +133,7 @@ class WebhooksCustomClientTest extends Scope
|
|||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertEquals($webhook['data']['name'], $name);
|
||||
$this->assertIsInt($webhook['data']['registration']);
|
||||
$this->assertIsString($webhook['data']['registration']);
|
||||
$this->assertEquals($webhook['data']['status'], false);
|
||||
$this->assertEquals($webhook['data']['email'], $email);
|
||||
$this->assertEquals($webhook['data']['emailVerification'], false);
|
||||
|
@ -455,7 +455,7 @@ class WebhooksCustomClientTest extends Scope
|
|||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertEquals($webhook['data']['name'], $newName);
|
||||
$this->assertIsInt($webhook['data']['registration']);
|
||||
$this->assertIsString($webhook['data']['registration']);
|
||||
$this->assertEquals($webhook['data']['status'], true);
|
||||
$this->assertEquals($webhook['data']['email'], $email);
|
||||
$this->assertEquals($webhook['data']['emailVerification'], false);
|
||||
|
@ -508,7 +508,7 @@ class WebhooksCustomClientTest extends Scope
|
|||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertEquals($webhook['data']['name'], 'New Name');
|
||||
$this->assertIsInt($webhook['data']['registration']);
|
||||
$this->assertIsString($webhook['data']['registration']);
|
||||
$this->assertEquals($webhook['data']['status'], true);
|
||||
$this->assertEquals($webhook['data']['email'], $email);
|
||||
$this->assertEquals($webhook['data']['emailVerification'], false);
|
||||
|
@ -563,7 +563,7 @@ class WebhooksCustomClientTest extends Scope
|
|||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertEquals($webhook['data']['name'], 'New Name');
|
||||
$this->assertIsInt($webhook['data']['registration']);
|
||||
$this->assertIsString($webhook['data']['registration']);
|
||||
$this->assertEquals($webhook['data']['status'], true);
|
||||
$this->assertEquals($webhook['data']['email'], $newEmail);
|
||||
$this->assertEquals($webhook['data']['emailVerification'], false);
|
||||
|
@ -619,7 +619,7 @@ class WebhooksCustomClientTest extends Scope
|
|||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertEquals($webhook['data']['name'], 'New Name');
|
||||
$this->assertIsInt($webhook['data']['registration']);
|
||||
$this->assertIsString($webhook['data']['registration']);
|
||||
$this->assertEquals($webhook['data']['status'], true);
|
||||
$this->assertEquals($webhook['data']['email'], $email);
|
||||
$this->assertEquals($webhook['data']['emailVerification'], false);
|
||||
|
|
|
@ -241,7 +241,7 @@ class WebhooksCustomServerTest extends Scope
|
|||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertEquals($webhook['data']['name'], $name);
|
||||
$this->assertIsInt($webhook['data']['registration']);
|
||||
$this->assertIsString($webhook['data']['registration']);
|
||||
$this->assertEquals($webhook['data']['status'], true);
|
||||
$this->assertEquals($webhook['data']['email'], $email);
|
||||
$this->assertEquals($webhook['data']['emailVerification'], false);
|
||||
|
@ -332,7 +332,7 @@ class WebhooksCustomServerTest extends Scope
|
|||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertEquals($webhook['data']['name'], $data['name']);
|
||||
$this->assertIsInt($webhook['data']['registration']);
|
||||
$this->assertIsString($webhook['data']['registration']);
|
||||
$this->assertEquals($webhook['data']['status'], false);
|
||||
$this->assertEquals($webhook['data']['email'], $data['email']);
|
||||
$this->assertEquals($webhook['data']['emailVerification'], false);
|
||||
|
@ -374,7 +374,7 @@ class WebhooksCustomServerTest extends Scope
|
|||
$this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide()));
|
||||
$this->assertNotEmpty($webhook['data']['$id']);
|
||||
$this->assertEquals($webhook['data']['name'], $data['name']);
|
||||
$this->assertIsInt($webhook['data']['registration']);
|
||||
$this->assertIsString($webhook['data']['registration']);
|
||||
$this->assertEquals($webhook['data']['status'], false);
|
||||
$this->assertEquals($webhook['data']['email'], $data['email']);
|
||||
$this->assertEquals($webhook['data']['emailVerification'], false);
|
||||
|
|
Loading…
Reference in a new issue