1
0
Fork 0
mirror of synced 2024-05-20 20:52:36 +12:00

Updated $uid to $id

This commit is contained in:
Eldad Fux 2020-02-17 09:16:11 +02:00
parent f433db17d0
commit 46cfa9ee92
58 changed files with 2053 additions and 727 deletions

View file

@ -130,9 +130,9 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
*/
if (null !== $key && $user->isEmpty()) {
$user = new Document([
'$uid' => 0,
'$id' => 0,
'status' => Auth::USER_STATUS_ACTIVATED,
'email' => 'app.'.$project->getUid().'@service.'.$domain,
'email' => 'app.'.$project->getId().'@service.'.$domain,
'password' => '',
'name' => $project->getAttribute('name', 'Untitled'),
]);
@ -143,7 +143,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
Authorization::setDefaultStatus(false); // Cancel security segmentation for API keys.
}
Authorization::setRole('user:'.$user->getUid());
Authorization::setRole('user:'.$user->getId());
Authorization::setRole('role:'.$role);
array_map(function ($node) {
@ -159,7 +159,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
// TDOO Check if user is god
if (!in_array($scope, $scopes)) {
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) { // Check if permission is denied because project is missing
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) { // Check if permission is denied because project is missing
throw new Exception('Project not found', 404);
}
@ -178,14 +178,14 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
* Background Jobs
*/
$webhook
->setParam('projectId', $project->getUid())
->setParam('projectId', $project->getId())
->setParam('event', $route->getLabel('webhook', ''))
->setParam('payload', [])
;
$audit
->setParam('projectId', $project->getUid())
->setParam('userId', $user->getUid())
->setParam('projectId', $project->getId())
->setParam('userId', $user->getId())
->setParam('event', '')
->setParam('resource', '')
->setParam('userAgent', $request->getServer('HTTP_USER_AGENT', ''))
@ -194,7 +194,7 @@ $utopia->init(function () use ($utopia, $request, $response, &$user, $project, $
;
$usage
->setParam('projectId', $project->getUid())
->setParam('projectId', $project->getId())
->setParam('url', $request->getServer('HTTP_HOST', '').$request->getServer('REQUEST_URI', ''))
->setParam('method', $request->getServer('REQUEST_METHOD', 'UNKNOWN'))
->setParam('request', 0)
@ -218,7 +218,7 @@ $utopia->shutdown(function () use ($response, $request, $webhook, $audit, $usage
$route = $utopia->match($request);
if($project->getUid()
if($project->getId()
&& $mode !== APP_MODE_ADMIN
&& !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage and admin mode
$usage
@ -369,11 +369,11 @@ $utopia->get('/v1/info') // This is only visible to gods
'environment' => $env,
'time' => date('Y-m-d H:i:s', time()),
'user' => [
'id' => $user->getUid(),
'id' => $user->getId(),
'name' => $user->getAttribute('name', ''),
],
'project' => [
'id' => $project->getUid(),
'id' => $project->getId(),
'name' => $project->getAttribute('name', ''),
],
]);

View file

@ -6,7 +6,7 @@ use Database\Database;
$collections = [
'console' => [
'$uid' => 'console',
'$id' => 'console',
'$collection' => 'projects',
'$permissions' => ['read' => ['*']],
'name' => 'Appwrite',
@ -71,7 +71,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_COLLECTIONS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$id' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$permissions' => ['read' => ['*']],
'name' => 'Collections',
'structure' => true,
@ -126,7 +126,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_RULES => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_RULES,
'$id' => Database::SYSTEM_COLLECTION_RULES,
'$permissions' => ['read' => ['*']],
'name' => 'Collections Rule',
'structure' => true,
@ -198,7 +198,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_USERS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_USERS,
'$id' => Database::SYSTEM_COLLECTION_USERS,
'$permissions' => ['read' => ['*']],
'name' => 'User',
'structure' => true,
@ -308,7 +308,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_TOKENS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_TOKENS,
'$id' => Database::SYSTEM_COLLECTION_TOKENS,
'$permissions' => ['read' => ['*']],
'name' => 'Token',
'structure' => true,
@ -362,7 +362,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_MEMBERSHIPS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_MEMBERSHIPS,
'$id' => Database::SYSTEM_COLLECTION_MEMBERSHIPS,
'$permissions' => ['read' => ['*']],
'name' => 'Membership',
'structure' => true,
@ -434,7 +434,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_TEAMS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_TEAMS,
'$id' => Database::SYSTEM_COLLECTION_TEAMS,
'$permissions' => ['read' => ['*']],
'name' => 'Team',
'structure' => true,
@ -470,7 +470,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_PROJECTS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_PROJECTS,
'$id' => Database::SYSTEM_COLLECTION_PROJECTS,
'$permissions' => ['read' => ['*']],
'name' => 'Project',
'structure' => true,
@ -610,7 +610,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_WEBHOOKS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_WEBHOOKS,
'$id' => Database::SYSTEM_COLLECTION_WEBHOOKS,
'$permissions' => ['read' => ['*']],
'name' => 'Webhook',
'structure' => true,
@ -673,7 +673,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_KEYS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_KEYS,
'$id' => Database::SYSTEM_COLLECTION_KEYS,
'$permissions' => ['read' => ['*']],
'name' => 'Key',
'structure' => true,
@ -708,7 +708,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_TASKS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_TASKS,
'$id' => Database::SYSTEM_COLLECTION_TASKS,
'$permissions' => ['read' => ['*']],
'name' => 'Task',
'structure' => true,
@ -861,7 +861,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_PLATFORMS => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_PLATFORMS,
'$id' => Database::SYSTEM_COLLECTION_PLATFORMS,
'$permissions' => ['read' => ['*']],
'name' => 'Platform',
'structure' => true,
@ -933,7 +933,7 @@ $collections = [
],
Database::SYSTEM_COLLECTION_FILES => [
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
'$uid' => Database::SYSTEM_COLLECTION_FILES,
'$id' => Database::SYSTEM_COLLECTION_FILES,
'$permissions' => ['read' => ['*']],
'name' => 'File',
'structure' => true,

View file

@ -55,7 +55,7 @@ $utopia->post('/v1/account')
->param('name', '', function () { return new Text(100); }, 'User name.', true)
->action(
function ($email, $password, $name) use ($register, $request, $response, $audit, $projectDB, $project, $webhook, $oauth2Keys) {
if ('console' === $project->getUid()) {
if ('console' === $project->getId()) {
$whitlistEmails = $project->getAttribute('authWhitelistEmails');
$whitlistIPs = $project->getAttribute('authWhitelistIPs');
$whitlistDomains = $project->getAttribute('authWhitelistDomains');
@ -118,16 +118,16 @@ $utopia->post('/v1/account')
;
$audit
->setParam('userId', $user->getUid())
->setParam('userId', $user->getId())
->setParam('event', 'account.create')
->setParam('resource', 'users/'.$user->getUid())
->setParam('resource', 'users/'.$user->getId())
;
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
->json(array_merge($user->getArrayCopy(array_merge(
[
'$uid',
'$id',
'email',
'registration',
'name',
@ -162,9 +162,9 @@ $utopia->post('/v1/account/sessions')
if (false == $profile || !Auth::passwordVerify($password, $profile->getAttribute('password'))) {
$audit
//->setParam('userId', $profile->getUid())
//->setParam('userId', $profile->getId())
->setParam('event', 'account.sesssions.failed')
->setParam('resource', 'users/'.($profile ? $profile->getUid() : ''))
->setParam('resource', 'users/'.($profile ? $profile->getId() : ''))
;
throw new Exception('Invalid credentials', 401); // Wrong password or username
@ -174,7 +174,7 @@ $utopia->post('/v1/account/sessions')
$secret = Auth::tokenGenerator();
$session = new Document([
'$collection' => Database::SYSTEM_COLLECTION_TOKENS,
'$permissions' => ['read' => ['user:'.$profile->getUid()], 'write' => ['user:'.$profile->getUid()]],
'$permissions' => ['read' => ['user:'.$profile->getId()], 'write' => ['user:'.$profile->getId()]],
'type' => Auth::TOKEN_TYPE_LOGIN,
'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak
'expire' => $expiry,
@ -182,7 +182,7 @@ $utopia->post('/v1/account/sessions')
'ip' => $request->getIP(),
]);
Authorization::setRole('user:'.$profile->getUid());
Authorization::setRole('user:'.$profile->getId());
$session = $projectDB->createDocument($session->getArrayCopy());
@ -206,16 +206,16 @@ $utopia->post('/v1/account/sessions')
;
$audit
->setParam('userId', $profile->getUid())
->setParam('userId', $profile->getId())
->setParam('event', 'account.sessions.create')
->setParam('resource', 'users/'.$profile->getUid())
->setParam('resource', 'users/'.$profile->getId())
;
$response
->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($profile->getUid(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null)
->addCookie(Auth::$cookieName, Auth::encodeSession($profile->getUid(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE)
->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($profile->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null)
->addCookie(Auth::$cookieName, Auth::encodeSession($profile->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE)
->setStatusCode(Response::STATUS_CODE_CREATED)
->json($session->getArrayCopy(['$uid', 'type', 'expire']))
->json($session->getArrayCopy(['$id', 'type', 'expire']))
;
}
);
@ -238,7 +238,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider')
->param('failure', '', function () use ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt.')
->action(
function ($provider, $success, $failure) use ($response, $request, $project) {
$callback = $request->getServer('REQUEST_SCHEME', 'https').'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getUid();
$callback = $request->getServer('REQUEST_SCHEME', 'https').'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId();
$appId = $project->getAttribute('usersOauth2'.ucfirst($provider).'Appid', '');
$appSecret = $project->getAttribute('usersOauth2'.ucfirst($provider).'Secret', '{}');
@ -294,7 +294,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
->param('state', '', function () { return new Text(2048); }, 'OAuth2 state params.', true)
->action(
function ($provider, $code, $state) use ($response, $request, $user, $projectDB, $project, $audit) {
$callback = $request->getServer('REQUEST_SCHEME', 'https').'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getUid();
$callback = $request->getServer('REQUEST_SCHEME', 'https').'://'.$request->getServer('HTTP_HOST').'/v1/account/sessions/oauth2/callback/'.$provider.'/'.$project->getId();
$defaultState = ['success' => $project->getAttribute('url', ''), 'failure' => ''];
$validateURL = new URL();
@ -360,7 +360,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
$projectDB->deleteDocument($current); //throw new Exception('User already logged in', 401);
}
$user = (empty($user->getUid())) ? $projectDB->getCollection([ // Get user by provider id
$user = (empty($user->getId())) ? $projectDB->getCollection([ // Get user by provider id
'limit' => 1,
'first' => true,
'filters' => [
@ -382,7 +382,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
],
]);
if (!$user || empty($user->getUid())) { // Last option -> create user alone, generate random password
if (!$user || empty($user->getId())) { // Last option -> create user alone, generate random password
Authorization::disable();
$user = $projectDB->createDocument([
@ -412,7 +412,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
$expiry = time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG;
$session = new Document([
'$collection' => Database::SYSTEM_COLLECTION_TOKENS,
'$permissions' => ['read' => ['user:'.$user['$uid']], 'write' => ['user:'.$user['$uid']]],
'$permissions' => ['read' => ['user:'.$user['$id']], 'write' => ['user:'.$user['$id']]],
'type' => Auth::TOKEN_TYPE_LOGIN,
'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak
'expire' => $expiry,
@ -427,7 +427,7 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
->setAttribute('tokens', $session, Document::SET_TYPE_APPEND)
;
Authorization::setRole('user:'.$user->getUid());
Authorization::setRole('user:'.$user->getId());
$user = $projectDB->updateDocument($user->getArrayCopy());
@ -436,15 +436,15 @@ $utopia->get('/v1/account/sessions/oauth2/:provider/redirect')
}
$audit
->setParam('userId', $user->getUid())
->setParam('userId', $user->getId())
->setParam('event', 'account.sessions.create')
->setParam('resource', 'users/'.$user->getUid())
->setParam('resource', 'users/'.$user->getId())
->setParam('data', ['provider' => $provider])
;
$response
->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($user->getUid(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null)
->addCookie(Auth::$cookieName, Auth::encodeSession($user->getUid(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE)
->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null)
->addCookie(Auth::$cookieName, Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE)
->redirect($state['success'])
;
}
@ -462,7 +462,7 @@ $utopia->get('/v1/account')
function () use ($response, &$user, $oauth2Keys) {
$response->json(array_merge($user->getArrayCopy(array_merge(
[
'$uid',
'$id',
'email',
'registration',
'name',
@ -525,7 +525,7 @@ $utopia->get('/v1/account/sessions')
$dd->parse();
$sessions[$index] = [
'$uid' => $token->getUid(),
'$id' => $token->getId(),
'OS' => $dd->getOs(),
'client' => $dd->getClient(),
'device' => $dd->getDevice(),
@ -533,7 +533,7 @@ $utopia->get('/v1/account/sessions')
'model' => $dd->getModel(),
'ip' => $token->getAttribute('ip', ''),
'geo' => [],
'current' => ($current == $token->getUid()) ? true : false,
'current' => ($current == $token->getId()) ? true : false,
];
try {
@ -562,12 +562,12 @@ $utopia->get('/v1/account/logs')
->action(
function () use ($response, $register, $project, $user) {
$adapter = new AuditAdapter($register->get('db'));
$adapter->setNamespace('app_'.$project->getUid());
$adapter->setNamespace('app_'.$project->getId());
$audit = new Audit($adapter);
$countries = Locale::getText('countries');
$logs = $audit->getLogsByUserAndActions($user->getUid(), [
$logs = $audit->getLogsByUserAndActions($user->getId(), [
'account.create',
'account.delete',
'account.update.name',
@ -644,14 +644,14 @@ $utopia->patch('/v1/account/name')
}
$audit
->setParam('userId', $user->getUid())
->setParam('userId', $user->getId())
->setParam('event', 'account.update.name')
->setParam('resource', 'users/'.$user->getUid())
->setParam('resource', 'users/'.$user->getId())
;
$response->json(array_merge($user->getArrayCopy(array_merge(
[
'$uid',
'$id',
'email',
'registration',
'name',
@ -686,14 +686,14 @@ $utopia->patch('/v1/account/password')
}
$audit
->setParam('userId', $user->getUid())
->setParam('userId', $user->getId())
->setParam('event', 'account.update.password')
->setParam('resource', 'users/'.$user->getUid())
->setParam('resource', 'users/'.$user->getId())
;
$response->json(array_merge($user->getArrayCopy(array_merge(
[
'$uid',
'$id',
'email',
'registration',
'name',
@ -744,14 +744,14 @@ $utopia->patch('/v1/account/email')
}
$audit
->setParam('userId', $user->getUid())
->setParam('userId', $user->getId())
->setParam('event', 'account.update.email')
->setParam('resource', 'users/'.$user->getUid())
->setParam('resource', 'users/'.$user->getId())
;
$response->json(array_merge($user->getArrayCopy(array_merge(
[
'$uid',
'$id',
'email',
'registration',
'name',
@ -785,7 +785,7 @@ $utopia->patch('/v1/account/prefs')
$audit
->setParam('event', 'account.update.prefs')
->setParam('resource', 'users/'.$user->getUid())
->setParam('resource', 'users/'.$user->getId())
;
$prefs = $user->getAttribute('prefs', '{}');
@ -828,9 +828,9 @@ $utopia->delete('/v1/account')
*/
$audit
->setParam('userId', $user->getUid())
->setParam('userId', $user->getId())
->setParam('event', 'account.delete')
->setParam('resource', 'users/'.$user->getUid())
->setParam('resource', 'users/'.$user->getId())
->setParam('data', $user->getArrayCopy())
;
@ -868,15 +868,15 @@ $utopia->delete('/v1/account/sessions/:sessionId')
$tokens = $user->getAttribute('tokens', []);
foreach ($tokens as $token) { /* @var $token Document */
if (($sessionId == $token->getUid()) && Auth::TOKEN_TYPE_LOGIN == $token->getAttribute('type')) {
if (!$projectDB->deleteDocument($token->getUid())) {
if (($sessionId == $token->getId()) && Auth::TOKEN_TYPE_LOGIN == $token->getAttribute('type')) {
if (!$projectDB->deleteDocument($token->getId())) {
throw new Exception('Failed to remove token from DB', 500);
}
$audit
->setParam('userId', $user->getUid())
->setParam('userId', $user->getId())
->setParam('event', 'account.sessions.delete')
->setParam('resource', '/user/'.$user->getUid())
->setParam('resource', '/user/'.$user->getId())
;
$webhook
@ -915,14 +915,14 @@ $utopia->delete('/v1/account/sessions')
$tokens = $user->getAttribute('tokens', []);
foreach ($tokens as $token) { /* @var $token Document */
if (!$projectDB->deleteDocument($token->getUid())) {
if (!$projectDB->deleteDocument($token->getId())) {
throw new Exception('Failed to remove token from DB', 500);
}
$audit
->setParam('userId', $user->getUid())
->setParam('userId', $user->getId())
->setParam('event', 'account.sessions.delete')
->setParam('resource', '/user/'.$user->getUid())
->setParam('resource', '/user/'.$user->getId())
;
$webhook
@ -973,7 +973,7 @@ $utopia->post('/v1/account/recovery')
$secret = Auth::tokenGenerator();
$recovery = new Document([
'$collection' => Database::SYSTEM_COLLECTION_TOKENS,
'$permissions' => ['read' => ['user:'.$profile->getUid()], 'write' => ['user:'.$profile->getUid()]],
'$permissions' => ['read' => ['user:'.$profile->getId()], 'write' => ['user:'.$profile->getId()]],
'type' => Auth::TOKEN_TYPE_RECOVERY,
'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak
'expire' => time() + Auth::TOKEN_EXPIRATION_RECOVERY,
@ -981,7 +981,7 @@ $utopia->post('/v1/account/recovery')
'ip' => $request->getIP(),
]);
Authorization::setRole('user:'.$profile->getUid());
Authorization::setRole('user:'.$profile->getId());
$recovery = $projectDB->createDocument($recovery->getArrayCopy());
@ -998,7 +998,7 @@ $utopia->post('/v1/account/recovery')
}
$url = Template::parseURL($url);
$url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $profile->getUid(), 'secret' => $secret]);
$url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $profile->getId(), 'secret' => $secret]);
$url = Template::unParseURL($url);
$body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.recovery.body'));
@ -1024,14 +1024,14 @@ $utopia->post('/v1/account/recovery')
}
$audit
->setParam('userId', $profile->getUid())
->setParam('userId', $profile->getId())
->setParam('event', 'account.recovery.create')
->setParam('resource', 'users/'.$profile->getUid())
->setParam('resource', 'users/'.$profile->getId())
;
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
->json($recovery->getArrayCopy(['$uid', 'type', 'expire']))
->json($recovery->getArrayCopy(['$id', 'type', 'expire']))
;
}
);
@ -1060,7 +1060,7 @@ $utopia->put('/v1/account/recovery')
'first' => true,
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_USERS,
'$uid='.$userId,
'$id='.$userId,
],
]);
@ -1074,7 +1074,7 @@ $utopia->put('/v1/account/recovery')
throw new Exception('Invalid recovery token', 401);
}
Authorization::setRole('user:'.$profile->getUid());
Authorization::setRole('user:'.$profile->getId());
$profile = $projectDB->updateDocument(array_merge($profile->getArrayCopy(), [
'password' => Auth::passwordHash($passwordA),
@ -1095,14 +1095,14 @@ $utopia->put('/v1/account/recovery')
}
$audit
->setParam('userId', $profile->getUid())
->setParam('userId', $profile->getId())
->setParam('event', 'account.recovery.update')
->setParam('resource', 'users/'.$profile->getUid())
->setParam('resource', 'users/'.$profile->getId())
;
$recovery = $profile->search('$uid', $recovery, $profile->getAttribute('tokens', []));
$recovery = $profile->search('$id', $recovery, $profile->getAttribute('tokens', []));
$response->json($recovery->getArrayCopy(['$uid', 'type', 'expire']));
$response->json($recovery->getArrayCopy(['$id', 'type', 'expire']));
}
);
@ -1122,7 +1122,7 @@ $utopia->post('/v1/account/verification')
$verification = new Document([
'$collection' => Database::SYSTEM_COLLECTION_TOKENS,
'$permissions' => ['read' => ['user:'.$user->getUid()], 'write' => ['user:'.$user->getUid()]],
'$permissions' => ['read' => ['user:'.$user->getId()], 'write' => ['user:'.$user->getId()]],
'type' => Auth::TOKEN_TYPE_VERIFICATION,
'secret' => Auth::hash($verificationSecret), // On way hash encryption to protect DB leak
'expire' => time() + Auth::TOKEN_EXPIRATION_CONFIRM,
@ -1130,7 +1130,7 @@ $utopia->post('/v1/account/verification')
'ip' => $request->getIP(),
]);
Authorization::setRole('user:'.$user->getUid());
Authorization::setRole('user:'.$user->getId());
$verification = $projectDB->createDocument($verification->getArrayCopy());
@ -1147,7 +1147,7 @@ $utopia->post('/v1/account/verification')
}
$url = Template::parseURL($url);
$url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $user->getUid(), 'secret' => $verificationSecret]);
$url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['userId' => $user->getId(), 'secret' => $verificationSecret]);
$url = Template::unParseURL($url);
$body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.verification.body'));
@ -1173,14 +1173,14 @@ $utopia->post('/v1/account/verification')
}
$audit
->setParam('userId', $user->getUid())
->setParam('userId', $user->getId())
->setParam('event', 'account.verification.create')
->setParam('resource', 'users/'.$user->getUid())
->setParam('resource', 'users/'.$user->getId())
;
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
->json($verification->getArrayCopy(['$uid', 'type', 'expire']))
->json($verification->getArrayCopy(['$id', 'type', 'expire']))
;
}
);
@ -1203,7 +1203,7 @@ $utopia->put('/v1/account/verification')
'first' => true,
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_USERS,
'$uid='.$userId,
'$id='.$userId,
],
]);
@ -1217,7 +1217,7 @@ $utopia->put('/v1/account/verification')
throw new Exception('Invalid verification token', 401);
}
Authorization::setRole('user:'.$profile->getUid());
Authorization::setRole('user:'.$profile->getId());
$profile = $projectDB->updateDocument(array_merge($profile->getArrayCopy(), [
'emailVerification' => true,
@ -1236,13 +1236,13 @@ $utopia->put('/v1/account/verification')
}
$audit
->setParam('userId', $profile->getUid())
->setParam('userId', $profile->getId())
->setParam('event', 'account.verification.update')
->setParam('resource', 'users/'.$user->getUid())
->setParam('resource', 'users/'.$user->getId())
;
$verification = $profile->search('$uid', $verification, $profile->getAttribute('tokens', []));
$verification = $profile->search('$id', $verification, $profile->getAttribute('tokens', []));
$response->json($verification->getArrayCopy(['$uid', 'type', 'expire']));
$response->json($verification->getArrayCopy(['$id', 'type', 'expire']));
}
);

View file

@ -78,7 +78,7 @@ $utopia->post('/v1/database/collections')
$audit
->setParam('event', 'database.collections.create')
->setParam('resource', 'database/collection/'.$data['$uid'])
->setParam('resource', 'database/collection/'.$data['$id'])
->setParam('data', $data)
;
@ -152,7 +152,7 @@ $utopia->get('/v1/database/collections/:collectionId')
function ($collectionId) use ($response, $projectDB) {
$collection = $projectDB->getDocument($collectionId, false);
if (empty($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
throw new Exception('Collection not found', 404);
}
@ -177,7 +177,7 @@ $utopia->put('/v1/database/collections/:collectionId')
function ($collectionId, $name, $read, $write, $rules) use ($response, $projectDB, $webhook, $audit) {
$collection = $projectDB->getDocument($collectionId, false);
if (empty($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
throw new Exception('Collection not found', 404);
}
@ -216,7 +216,7 @@ $utopia->put('/v1/database/collections/:collectionId')
$audit
->setParam('event', 'database.collections.update')
->setParam('resource', 'database/collections/'.$data['$uid'])
->setParam('resource', 'database/collections/'.$data['$id'])
->setParam('data', $data)
;
@ -237,7 +237,7 @@ $utopia->delete('/v1/database/collections/:collectionId')
function ($collectionId) use ($response, $projectDB, $webhook, $audit) {
$collection = $projectDB->getDocument($collectionId, false);
if (empty($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
throw new Exception('Collection not found', 404);
}
@ -253,7 +253,7 @@ $utopia->delete('/v1/database/collections/:collectionId')
$audit
->setParam('event', 'database.collections.delete')
->setParam('resource', 'database/collections/'.$data['$uid'])
->setParam('resource', 'database/collections/'.$data['$id'])
->setParam('data', $data)
;
@ -284,13 +284,13 @@ $utopia->post('/v1/database/collections/:collectionId/documents')
throw new Exception('Missing payload', 400);
}
if (isset($data['$uid'])) {
throw new Exception('$uid is not allowed for creating new documents, try update instead', 400);
if (isset($data['$id'])) {
throw new Exception('$id is not allowed for creating new documents, try update instead', 400);
}
$collection = $projectDB->getDocument($collectionId/*, $isDev*/);
if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
if (is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
throw new Exception('Collection not found', 404);
}
@ -354,7 +354,7 @@ $utopia->post('/v1/database/collections/:collectionId/documents')
$audit
->setParam('event', 'database.documents.create')
->setParam('resource', 'database/document/'.$data['$uid'])
->setParam('resource', 'database/document/'.$data['$id'])
->setParam('data', $data)
;
@ -376,10 +376,10 @@ $utopia->get('/v1/database/collections/:collectionId/documents')
->label('sdk.method', 'listDocuments')
->label('sdk.description', '/docs/references/database/list-documents.md')
->param('collectionId', null, function () { return new UID(); }, 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/database?platform=server#createCollection).')
->param('filters', [], function () { return new ArrayList(new Text(128)); }, 'Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: \'name=John Doe\' or \'category.$uid>=5bed2d152c362\'.', true)
->param('filters', [], function () { return new ArrayList(new Text(128)); }, 'Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, >, <, <=, >=) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: \'name=John Doe\' or \'category.$id>=5bed2d152c362\'.', true)
->param('offset', 0, function () { return new Range(0, 900000000); }, 'Offset value. Use this value to manage pagination.', true)
->param('limit', 50, function () { return new Range(0, 1000); }, 'Maximum number of documents to return in response. Use this value to manage pagination.', true)
->param('order-field', '$uid', function () { return new Text(128); }, 'Document field that results will be sorted by.', true)
->param('order-field', '$id', function () { return new Text(128); }, 'Document field that results will be sorted by.', true)
->param('order-type', 'ASC', function () { return new WhiteList(array('DESC', 'ASC')); }, 'Order direction. Possible values are DESC for descending order, or ASC for ascending order.', true)
->param('order-cast', 'string', function () { return new WhiteList(array('int', 'string', 'date', 'time', 'datetime')); }, 'Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string.', true)
->param('search', '', function () { return new Text(256); }, 'Search query. Enter any free text search. The database will try to find a match against all document attributes and children.', true)
@ -389,7 +389,7 @@ $utopia->get('/v1/database/collections/:collectionId/documents')
function ($collectionId, $filters, $offset, $limit, $orderField, $orderType, $orderCast, $search, $first, $last) use ($response, $projectDB, $isDev) {
$collection = $projectDB->getDocument($collectionId, $isDev);
if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
if (is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
throw new Exception('Collection not found', 404);
}
@ -430,7 +430,7 @@ $utopia->get('/v1/database/collections/:collectionId/documents')
/*
* View
*/
$response->json($collection->getArrayCopy(/*['$uid', '$collection', 'name', 'documents']*/[], ['rules']));
$response->json($collection->getArrayCopy(/*['$id', '$collection', 'name', 'documents']*/[], ['rules']));
}
}
);
@ -449,7 +449,7 @@ $utopia->get('/v1/database/collections/:collectionId/documents/:documentId')
$document = $projectDB->getDocument($documentId, $isDev);
$collection = $projectDB->getDocument($collectionId, $isDev);
if (empty($document->getArrayCopy()) || $document->getCollection() != $collection->getUid()) { // Check empty
if (empty($document->getArrayCopy()) || $document->getCollection() != $collection->getId()) { // Check empty
throw new Exception('No document found', 404);
}
@ -463,7 +463,7 @@ $utopia->get('/v1/database/collections/:collectionId/documents/:documentId')
$output = $document->getAttribute(implode('.', $paths));
} else {
$id = (int) array_pop($paths);
$output = $document->search('$uid', $id, $document->getAttribute(implode('.', $paths)));
$output = $document->search('$id', $id, $document->getAttribute(implode('.', $paths)));
}
$output = ($output instanceof Document) ? $output->getArrayCopy() : $output;
@ -504,7 +504,7 @@ $utopia->patch('/v1/database/collections/:collectionId/documents/:documentId')
throw new Exception('Data param should be a valid JSON', 400);
}
if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
if (is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
throw new Exception('Collection not found', 404);
}
@ -524,8 +524,8 @@ $utopia->patch('/v1/database/collections/:collectionId/documents/:documentId')
$data = array_merge($document->getArrayCopy(), $data);
$data['$collection'] = $collection->getUid(); // Make sure user don't switch collectionID
$data['$uid'] = $document->getUid(); // Make sure user don't switch document unique ID
$data['$collection'] = $collection->getId(); // Make sure user don't switch collectionID
$data['$id'] = $document->getId(); // Make sure user don't switch document unique ID
if (empty($data)) {
throw new Exception('Missing payload', 400);
@ -548,7 +548,7 @@ $utopia->patch('/v1/database/collections/:collectionId/documents/:documentId')
$audit
->setParam('event', 'database.documents.update')
->setParam('resource', 'database/document/'.$data['$uid'])
->setParam('resource', 'database/document/'.$data['$id'])
->setParam('data', $data)
;
@ -578,7 +578,7 @@ $utopia->delete('/v1/database/collections/:collectionId/documents/:documentId')
throw new Exception('No document found', 404);
}
if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
if (is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
throw new Exception('Collection not found', 404);
}
@ -600,7 +600,7 @@ $utopia->delete('/v1/database/collections/:collectionId/documents/:documentId')
$audit
->setParam('event', 'database.documents.delete')
->setParam('resource', 'database/document/'.$data['$uid'])
->setParam('resource', 'database/document/'.$data['$id'])
->setParam('data', $data) // Audit document in case of malicious or disastrous action
;

View file

@ -41,7 +41,7 @@ $utopia->post('/v1/projects')
function ($name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId) use ($response, $user, $consoleDB, $projectDB) {
$team = $projectDB->getDocument($teamId);
if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
throw new Exception('Team not found', 404);
}
@ -62,7 +62,7 @@ $utopia->post('/v1/projects')
'legalCity' => $legalCity,
'legalAddress' => $legalAddress,
'legalTaxId' => $legalTaxId,
'teamId' => $team->getUid(),
'teamId' => $team->getId(),
'platforms' => [],
'webhooks' => [],
'keys' => [],
@ -74,7 +74,7 @@ $utopia->post('/v1/projects')
throw new Exception('Failed saving project to DB', 500);
}
$consoleDB->createNamespace($project->getUid());
$consoleDB->createNamespace($project->getId());
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
@ -126,7 +126,7 @@ $utopia->get('/v1/projects/:projectId')
function ($projectId) use ($request, $response, $providers, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -153,7 +153,7 @@ $utopia->get('/v1/projects/:projectId/usage')
function ($projectId) use ($response, $consoleDB, $projectDB, $register) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -170,7 +170,7 @@ $utopia->get('/v1/projects/:projectId/usage')
$database = $client->selectDB('telegraf');
// Requests
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getUid().'\' GROUP BY time(1d) FILL(null)');
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_requests_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time(1d) FILL(null)');
$points = $result->getPoints();
foreach ($points as $point) {
@ -181,7 +181,7 @@ $utopia->get('/v1/projects/:projectId/usage')
}
// Network
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getUid().'\' GROUP BY time(1d) FILL(null)');
$result = $database->query('SELECT sum(value) AS "value" FROM "appwrite_usage_network_all" WHERE time > \''.$start.'\' AND time < \''.$end.'\' AND "metric_type"=\'counter\' AND "project"=\''.$project->getId().'\' GROUP BY time(1d) FILL(null)');
$points = $result->getPoints();
foreach ($points as $point) {
@ -223,7 +223,7 @@ $utopia->get('/v1/projects/:projectId/usage')
'limit' => 0,
'offset' => 0,
'filters' => [
'$collection='.$collection['$uid'],
'$collection='.$collection['$id'],
],
]);
@ -297,7 +297,7 @@ $utopia->patch('/v1/projects/:projectId')
function ($projectId, $name, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -335,7 +335,7 @@ $utopia->patch('/v1/projects/:projectId/oauth2')
function ($projectId, $provider, $appId, $secret) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -378,7 +378,7 @@ $utopia->delete('/v1/projects/:projectId')
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -389,7 +389,7 @@ $utopia->delete('/v1/projects/:projectId')
}
// Delete all DBs
// $consoleDB->deleteNamespace($project->getUid());
// $consoleDB->deleteNamespace($project->getId());
// Optimize DB?
@ -418,7 +418,7 @@ $utopia->post('/v1/projects/:projectId/webhooks')
function ($projectId, $name, $events, $url, $security, $httpUser, $httpPass) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -476,7 +476,7 @@ $utopia->get('/v1/projects/:projectId/webhooks')
function ($projectId) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -509,11 +509,11 @@ $utopia->get('/v1/projects/:projectId/webhooks/:webhookId')
function ($projectId, $webhookId) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$webhook = $project->search('$uid', $webhookId, $project->getAttribute('webhooks', []));
$webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', []));
if (empty($webhook) && $webhook instanceof Document) {
throw new Exception('Webhook not found', 404);
@ -548,7 +548,7 @@ $utopia->put('/v1/projects/:projectId/webhooks/:webhookId')
function ($projectId, $webhookId, $name, $events, $url, $security, $httpUser, $httpPass) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -563,7 +563,7 @@ $utopia->put('/v1/projects/:projectId/webhooks/:webhookId')
'version' => '1',
]);
$webhook = $project->search('$uid', $webhookId, $project->getAttribute('webhooks', []));
$webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', []));
if (empty($webhook) && $webhook instanceof Document) {
throw new Exception('Webhook not found', 404);
@ -597,17 +597,17 @@ $utopia->delete('/v1/projects/:projectId/webhooks/:webhookId')
function ($projectId, $webhookId) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$webhook = $project->search('$uid', $webhookId, $project->getAttribute('webhooks', []));
$webhook = $project->search('$id', $webhookId, $project->getAttribute('webhooks', []));
if (empty($webhook) && $webhook instanceof Document) {
throw new Exception('Webhook not found', 404);
}
if (!$consoleDB->deleteDocument($webhook->getUid())) {
if (!$consoleDB->deleteDocument($webhook->getId())) {
throw new Exception('Failed to remove webhook from DB', 500);
}
@ -629,7 +629,7 @@ $utopia->post('/v1/projects/:projectId/keys')
function ($projectId, $name, $scopes) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -673,7 +673,7 @@ $utopia->get('/v1/projects/:projectId/keys')
function ($projectId) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -692,11 +692,11 @@ $utopia->get('/v1/projects/:projectId/keys/:keyId')
function ($projectId, $keyId) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$key = $project->search('$uid', $keyId, $project->getAttribute('keys', []));
$key = $project->search('$id', $keyId, $project->getAttribute('keys', []));
if (empty($key) && $key instanceof Document) {
throw new Exception('Key not found', 404);
@ -719,11 +719,11 @@ $utopia->put('/v1/projects/:projectId/keys/:keyId')
function ($projectId, $keyId, $name, $scopes) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$key = $project->search('$uid', $keyId, $project->getAttribute('keys', []));
$key = $project->search('$id', $keyId, $project->getAttribute('keys', []));
if (empty($key) && $key instanceof Document) {
throw new Exception('Key not found', 404);
@ -753,17 +753,17 @@ $utopia->delete('/v1/projects/:projectId/keys/:keyId')
function ($projectId, $keyId) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$key = $project->search('$uid', $keyId, $project->getAttribute('keys', []));
$key = $project->search('$id', $keyId, $project->getAttribute('keys', []));
if (empty($key) && $key instanceof Document) {
throw new Exception('Key not found', 404);
}
if (!$consoleDB->deleteDocument($key->getUid())) {
if (!$consoleDB->deleteDocument($key->getId())) {
throw new Exception('Failed to remove key from DB', 500);
}
@ -792,7 +792,7 @@ $utopia->post('/v1/projects/:projectId/tasks')
function ($projectId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -865,7 +865,7 @@ $utopia->get('/v1/projects/:projectId/tasks')
function ($projectId) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -898,11 +898,11 @@ $utopia->get('/v1/projects/:projectId/tasks/:taskId')
function ($projectId, $taskId) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$task = $project->search('$uid', $taskId, $project->getAttribute('tasks', []));
$task = $project->search('$id', $taskId, $project->getAttribute('tasks', []));
if (empty($task) && $task instanceof Document) {
throw new Exception('Task not found', 404);
@ -939,11 +939,11 @@ $utopia->put('/v1/projects/:projectId/tasks/:taskId')
function ($projectId, $taskId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$task = $project->search('$uid', $taskId, $project->getAttribute('tasks', []));
$task = $project->search('$id', $taskId, $project->getAttribute('tasks', []));
if (empty($task) && $task instanceof Document) {
throw new Exception('Task not found', 404);
@ -1000,17 +1000,17 @@ $utopia->delete('/v1/projects/:projectId/tasks/:taskId')
function ($projectId, $taskId) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$task = $project->search('$uid', $taskId, $project->getAttribute('tasks', []));
$task = $project->search('$id', $taskId, $project->getAttribute('tasks', []));
if (empty($task) && $task instanceof Document) {
throw new Exception('Task not found', 404);
}
if (!$consoleDB->deleteDocument($task->getUid())) {
if (!$consoleDB->deleteDocument($task->getId())) {
throw new Exception('Failed to remove tasks from DB', 500);
}
@ -1035,7 +1035,7 @@ $utopia->post('/v1/projects/:projectId/platforms')
function ($projectId, $type, $name, $key, $store, $url) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -1083,7 +1083,7 @@ $utopia->get('/v1/projects/:projectId/platforms')
function ($projectId) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
@ -1104,11 +1104,11 @@ $utopia->get('/v1/projects/:projectId/platforms/:platformId')
function ($projectId, $platformId) use ($request, $response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$platform = $project->search('$uid', $platformId, $project->getAttribute('platforms', []));
$platform = $project->search('$id', $platformId, $project->getAttribute('platforms', []));
if (empty($platform) && $platform instanceof Document) {
throw new Exception('Platform not found', 404);
@ -1133,11 +1133,11 @@ $utopia->put('/v1/projects/:projectId/platforms/:platformId')
function ($projectId, $platformId, $name, $key, $store, $url) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$platform = $project->search('$uid', $platformId, $project->getAttribute('platforms', []));
$platform = $project->search('$id', $platformId, $project->getAttribute('platforms', []));
if (empty($platform) && $platform instanceof Document) {
throw new Exception('Platform not found', 404);
@ -1170,17 +1170,17 @@ $utopia->delete('/v1/projects/:projectId/platforms/:platformId')
function ($projectId, $platformId) use ($response, $consoleDB) {
$project = $consoleDB->getDocument($projectId);
if (empty($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
if (empty($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS != $project->getCollection()) {
throw new Exception('Project not found', 404);
}
$platform = $project->search('$uid', $platformId, $project->getAttribute('platforms', []));
$platform = $project->search('$id', $platformId, $project->getAttribute('platforms', []));
if (empty($platform) && $platform instanceof Document) {
throw new Exception('Platform not found', 404);
}
if (!$consoleDB->deleteDocument($platform->getUid())) {
if (!$consoleDB->deleteDocument($platform->getId())) {
throw new Exception('Failed to remove platform from DB', 500);
}

View file

@ -25,7 +25,7 @@ use OpenSSL\OpenSSL;
include_once __DIR__ . '/../shared/api.php';
Storage::addDevice('local', new Local('/storage/uploads/app-'.$project->getUid()));
Storage::addDevice('local', new Local('/storage/uploads/app-'.$project->getId()));
$fileLogos = [ // Based on this list @see http://stackoverflow.com/a/4212908/2299554
'default' => 'default.gif',
@ -132,8 +132,8 @@ $utopia->post('/v1/storage/files')
->action(
function ($file, $read, $write, $folderId = '') use ($request, $response, $user, $projectDB, $webhook, $audit, $usage) {
$file = $request->getFiles('file');
$read = (empty($read)) ? ['user:'.$user->getUid()] : $read;
$write = (empty($write)) ? ['user:'.$user->getUid()] : $write;
$read = (empty($read)) ? ['user:'.$user->getId()] : $read;
$write = (empty($write)) ? ['user:'.$user->getId()] : $write;
/*
* Validators
@ -236,7 +236,7 @@ $utopia->post('/v1/storage/files')
$audit
->setParam('event', 'storage.files.create')
->setParam('resource', 'storage/files/'.$file->getUid())
->setParam('resource', 'storage/files/'.$file->getId())
;
$usage
@ -276,7 +276,7 @@ $utopia->get('/v1/storage/files')
]);
$results = array_map(function ($value) { /* @var $value \Database\Document */
return $value->getArrayCopy(['$uid', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal']);
return $value->getArrayCopy(['$id', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal']);
}, $results);
$response->json(['sum' => $projectDB->getSum(), 'files' => $results]);
@ -295,11 +295,11 @@ $utopia->get('/v1/storage/files/:fileId')
function ($fileId) use ($response, $projectDB) {
$file = $projectDB->getDocument($fileId);
if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
throw new Exception('File not found', 404);
}
$response->json($file->getArrayCopy(['$uid', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal']));
$response->json($file->getArrayCopy(['$id', '$permissions', 'name', 'dateCreated', 'signature', 'mimeType', 'sizeOriginal']));
}
);
@ -341,7 +341,7 @@ $utopia->get('/v1/storage/files/:fileId/preview')
$file = $projectDB->getDocument($fileId);
if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
throw new Exception('File not found', 404);
}
@ -357,7 +357,7 @@ $utopia->get('/v1/storage/files/:fileId/preview')
throw new Exception('File not found in '.$path, 404);
}
$cache = new Cache(new Filesystem('/storage/cache/app-'.$project->getUid())); // Limit file number or size
$cache = new Cache(new Filesystem('/storage/cache/app-'.$project->getId())); // Limit file number or size
$data = $cache->load($key, 60 * 60 * 24 * 30 * 3 /* 3 months */);
if ($data) {
@ -367,8 +367,10 @@ $utopia->get('/v1/storage/files/:fileId/preview')
->setContentType((in_array($output, $outputs)) ? $outputs[$output] : $outputs['jpg'])
->addHeader('Expires', $date)
->addHeader('X-Appwrite-Cache', 'hit')
->send($data, 0)
->send($data)
;
return;
}
$source = $device->read($path);
@ -402,7 +404,7 @@ $utopia->get('/v1/storage/files/:fileId/preview')
->setContentType($outputs[$output])
->addHeader('Expires', $date)
->addHeader('X-Appwrite-Cache', 'miss')
->send('', null)
->send('')
;
$data = $resize->output($output, $quality);
@ -412,8 +414,6 @@ $utopia->get('/v1/storage/files/:fileId/preview')
echo $data;
unset($resize);
exit(0);
}
);
@ -431,7 +431,7 @@ $utopia->get('/v1/storage/files/:fileId/download')
function ($fileId) use ($response, $request, $projectDB) {
$file = $projectDB->getDocument($fileId);
if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
throw new Exception('File not found', 404);
}
@ -485,7 +485,7 @@ $utopia->get('/v1/storage/files/:fileId/view')
function ($fileId, $as) use ($response, $request, $projectDB, $mimes) {
$file = $projectDB->getDocument($fileId);
if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
throw new Exception('File not found', 404);
}
@ -556,7 +556,7 @@ $utopia->put('/v1/storage/files/:fileId')
function ($fileId, $read, $write, $folderId = '') use ($response, $projectDB, $audit, $webhook) {
$file = $projectDB->getDocument($fileId);
if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
throw new Exception('File not found', 404);
}
@ -578,7 +578,7 @@ $utopia->put('/v1/storage/files/:fileId')
$audit
->setParam('event', 'storage.files.update')
->setParam('resource', 'storage/files/'.$file->getUid())
->setParam('resource', 'storage/files/'.$file->getId())
;
$response->json($file->getArrayCopy());
@ -598,7 +598,7 @@ $utopia->delete('/v1/storage/files/:fileId')
function ($fileId) use ($response, $projectDB, $webhook, $audit, $usage) {
$file = $projectDB->getDocument($fileId);
if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
throw new Exception('File not found', 404);
}
@ -616,7 +616,7 @@ $utopia->delete('/v1/storage/files/:fileId')
$audit
->setParam('event', 'storage.files.delete')
->setParam('resource', 'storage/files/'.$file->getUid())
->setParam('resource', 'storage/files/'.$file->getId())
;
$usage
@ -640,7 +640,7 @@ $utopia->get('/v1/storage/files/:fileId/scan')
function ($fileId, $storage) use ($response, $request, $projectDB) {
$file = $projectDB->getDocument($fileId);
if (empty($file->getUid()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
if (empty($file->getId()) || Database::SYSTEM_COLLECTION_FILES != $file->getCollection()) {
throw new Exception('File not found', 404);
}

View file

@ -40,7 +40,7 @@ $utopia->post('/v1/teams')
'write' => ['team:{self}/owner'],
],
'name' => $name,
'sum' => ($mode !== APP_MODE_ADMIN && $user->getUid()) ? 1 : 0,
'sum' => ($mode !== APP_MODE_ADMIN && $user->getId()) ? 1 : 0,
'dateCreated' => time(),
]);
@ -50,15 +50,15 @@ $utopia->post('/v1/teams')
throw new Exception('Failed saving team to DB', 500);
}
if ($mode !== APP_MODE_ADMIN && $user->getUid()) { // Don't add user on server mode
if ($mode !== APP_MODE_ADMIN && $user->getId()) { // Don't add user on server mode
$membership = new Document([
'$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS,
'$permissions' => [
'read' => ['user:'.$user->getUid(), 'team:'.$team->getUid()],
'write' => ['user:'.$user->getUid(), 'team:'.$team->getUid().'/owner'],
'read' => ['user:'.$user->getId(), 'team:'.$team->getId()],
'write' => ['user:'.$user->getId(), 'team:'.$team->getId().'/owner'],
],
'userId' => $user->getUid(),
'teamId' => $team->getUid(),
'userId' => $user->getId(),
'teamId' => $team->getId(),
'roles' => $roles,
'invited' => time(),
'joined' => time(),
@ -124,7 +124,7 @@ $utopia->get('/v1/teams/:teamId')
function ($teamId) use ($response, $projectDB) {
$team = $projectDB->getDocument($teamId);
if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
throw new Exception('Team not found', 404);
}
@ -145,7 +145,7 @@ $utopia->put('/v1/teams/:teamId')
function ($teamId, $name) use ($response, $projectDB) {
$team = $projectDB->getDocument($teamId);
if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
throw new Exception('Team not found', 404);
}
@ -173,7 +173,7 @@ $utopia->delete('/v1/teams/:teamId')
function ($teamId) use ($response, $projectDB) {
$team = $projectDB->getDocument($teamId);
if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
throw new Exception('Team not found', 404);
}
@ -187,7 +187,7 @@ $utopia->delete('/v1/teams/:teamId')
]);
foreach ($memberships as $member) {
if (!$projectDB->deleteDocument($member->getUid())) {
if (!$projectDB->deleteDocument($member->getId())) {
throw new Exception('Failed to remove membership for team from DB', 500);
}
}
@ -217,7 +217,7 @@ $utopia->post('/v1/teams/:teamId/memberships')
$name = (empty($name)) ? $email : $name;
$team = $projectDB->getDocument($teamId);
if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
throw new Exception('Team not found', 404);
}
@ -226,7 +226,7 @@ $utopia->post('/v1/teams/:teamId/memberships')
'offset' => 0,
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_MEMBERSHIPS,
'teamId='.$team->getUid(),
'teamId='.$team->getId(),
],
]);
@ -270,11 +270,11 @@ $utopia->post('/v1/teams/:teamId/memberships')
$isOwner = false;
foreach ($memberships as $member) {
if ($member->getAttribute('userId') == $invitee->getUid()) {
if ($member->getAttribute('userId') == $invitee->getId()) {
throw new Exception('User has already been invited or is already a member of this team', 409);
}
if ($member->getAttribute('userId') == $user->getUid() && in_array('owner', $member->getAttribute('roles', []))) {
if ($member->getAttribute('userId') == $user->getId() && in_array('owner', $member->getAttribute('roles', []))) {
$isOwner = true;
}
}
@ -289,10 +289,10 @@ $utopia->post('/v1/teams/:teamId/memberships')
'$collection' => Database::SYSTEM_COLLECTION_MEMBERSHIPS,
'$permissions' => [
'read' => ['*'],
'write' => ['user:'.$invitee->getUid(), 'team:'.$team->getUid().'/owner'],
'write' => ['user:'.$invitee->getId(), 'team:'.$team->getId().'/owner'],
],
'userId' => $invitee->getUid(),
'teamId' => $team->getUid(),
'userId' => $invitee->getId(),
'teamId' => $team->getId(),
'roles' => $roles,
'invited' => time(),
'joined' => 0,
@ -307,7 +307,7 @@ $utopia->post('/v1/teams/:teamId/memberships')
}
$url = Template::parseURL($url);
$url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['inviteId' => $membership->getUid(), 'teamId' => $team->getUid(), 'userId' => $invitee->getUid(), 'secret' => $secret, 'teamId' => $teamId]);
$url['query'] = Template::mergeQuery(((isset($url['query'])) ? $url['query'] : ''), ['inviteId' => $membership->getId(), 'teamId' => $team->getId(), 'userId' => $invitee->getId(), 'secret' => $secret, 'teamId' => $teamId]);
$url = Template::unParseURL($url);
$body = new Template(__DIR__.'/../../config/locales/templates/'.Locale::getText('account.emails.invitation.body'));
@ -334,7 +334,7 @@ $utopia->post('/v1/teams/:teamId/memberships')
}
$audit
->setParam('userId', $invitee->getUid())
->setParam('userId', $invitee->getId())
->setParam('event', 'teams.membership.create')
->setParam('resource', 'teams/'.$teamId)
;
@ -342,7 +342,7 @@ $utopia->post('/v1/teams/:teamId/memberships')
$response
->setStatusCode(Response::STATUS_CODE_CREATED) // TODO change response of this endpoint
->json(array_merge($membership->getArrayCopy([
'$uid',
'$id',
'userId',
'teamId',
'roles',
@ -369,7 +369,7 @@ $utopia->get('/v1/teams/:teamId/memberships')
function ($teamId) use ($response, $projectDB) {
$team = $projectDB->getDocument($teamId);
if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
throw new Exception('Team not found', 404);
}
@ -392,7 +392,7 @@ $utopia->get('/v1/teams/:teamId/memberships')
$temp = $projectDB->getDocument($membership->getAttribute('userId', null))->getArrayCopy(['email', 'name']);
$users[] = array_merge($temp, $membership->getArrayCopy([
'$uid',
'$id',
'userId',
'teamId',
'roles',
@ -429,7 +429,7 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status')
function ($teamId, $inviteId, $userId, $secret) use ($response, $request, $user, $audit, $projectDB) {
$membership = $projectDB->getDocument($inviteId);
if (empty($membership->getUid()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) {
if (empty($membership->getId()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) {
throw new Exception('Invite not found', 404);
}
@ -443,7 +443,7 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status')
Authorization::reset();
if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
throw new Exception('Team not found', 404);
}
@ -455,18 +455,18 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status')
throw new Exception('Invite not belong to current user ('.$user->getAttribute('email').')', 401);
}
if (empty($user->getUid())) {
if (empty($user->getId())) {
$user = $projectDB->getCollection([ // Get user
'limit' => 1,
'first' => true,
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_USERS,
'$uid='.$userId,
'$id='.$userId,
],
]);
}
if ($membership->getAttribute('userId') !== $user->getUid()) {
if ($membership->getAttribute('userId') !== $user->getId()) {
throw new Exception('Invite not belong to current user ('.$user->getAttribute('email').')', 401);
}
@ -486,7 +486,7 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status')
$user->setAttribute('tokens', new Document([
'$collection' => Database::SYSTEM_COLLECTION_TOKENS,
'$permissions' => ['read' => ['user:'.$user->getUid()], 'write' => ['user:'.$user->getUid()]],
'$permissions' => ['read' => ['user:'.$user->getId()], 'write' => ['user:'.$user->getId()]],
'type' => Auth::TOKEN_TYPE_LOGIN,
'secret' => Auth::hash($secret), // On way hash encryption to protect DB leak
'expire' => $expiry,
@ -515,16 +515,16 @@ $utopia->patch('/v1/teams/:teamId/memberships/:inviteId/status')
}
$audit
->setParam('userId', $user->getUid())
->setParam('userId', $user->getId())
->setParam('event', 'teams.membership.update')
->setParam('resource', 'teams/'.$teamId)
;
$response
->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($user->getUid(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null)
->addCookie(Auth::$cookieName, Auth::encodeSession($user->getUid(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE)
->addCookie(Auth::$cookieName.'_legacy', Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, null)
->addCookie(Auth::$cookieName, Auth::encodeSession($user->getId(), $secret), $expiry, '/', COOKIE_DOMAIN, ('https' == $request->getServer('REQUEST_SCHEME', 'https')), true, COOKIE_SAMESITE)
->json(array_merge($membership->getArrayCopy([
'$uid',
'$id',
'userId',
'teamId',
'roles',
@ -552,7 +552,7 @@ $utopia->delete('/v1/teams/:teamId/memberships/:inviteId')
function ($teamId, $inviteId) use ($response, $projectDB, $audit) {
$membership = $projectDB->getDocument($inviteId);
if (empty($membership->getUid()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) {
if (empty($membership->getId()) || Database::SYSTEM_COLLECTION_MEMBERSHIPS != $membership->getCollection()) {
throw new Exception('Invite not found', 404);
}
@ -562,11 +562,11 @@ $utopia->delete('/v1/teams/:teamId/memberships/:inviteId')
$team = $projectDB->getDocument($teamId);
if (empty($team->getUid()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
if (empty($team->getId()) || Database::SYSTEM_COLLECTION_TEAMS != $team->getCollection()) {
throw new Exception('Team not found', 404);
}
if (!$projectDB->deleteDocument($membership->getUid())) {
if (!$projectDB->deleteDocument($membership->getId())) {
throw new Exception('Failed to remove membership from DB', 500);
}

View file

@ -76,7 +76,7 @@ $utopia->post('/v1/users')
$response
->setStatusCode(Response::STATUS_CODE_CREATED)
->json(array_merge($user->getArrayCopy(array_merge([
'$uid',
'$id',
'status',
'email',
'registration',
@ -125,7 +125,7 @@ $utopia->get('/v1/users')
$results = array_map(function ($value) use ($oauth2Keys) { /* @var $value \Database\Document */
return $value->getArrayCopy(array_merge(
[
'$uid',
'$id',
'status',
'email',
'registration',
@ -152,7 +152,7 @@ $utopia->get('/v1/users/:userId')
function ($userId) use ($response, $projectDB, $providers) {
$user = $projectDB->getDocument($userId);
if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
throw new Exception('User not found', 404);
}
@ -169,7 +169,7 @@ $utopia->get('/v1/users/:userId')
$response->json(array_merge($user->getArrayCopy(array_merge(
[
'$uid',
'$id',
'status',
'email',
'registration',
@ -193,7 +193,7 @@ $utopia->get('/v1/users/:userId/prefs')
function ($userId) use ($response, $projectDB) {
$user = $projectDB->getDocument($userId);
if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
throw new Exception('User not found', 404);
}
@ -222,7 +222,7 @@ $utopia->get('/v1/users/:userId/sessions')
function ($userId) use ($response, $projectDB) {
$user = $projectDB->getDocument($userId);
if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
throw new Exception('User not found', 404);
}
@ -247,7 +247,7 @@ $utopia->get('/v1/users/:userId/sessions')
$dd->parse();
$sessions[$index] = [
'$uid' => $token->getUid(),
'$id' => $token->getId(),
'OS' => $dd->getOs(),
'client' => $dd->getClient(),
'device' => $dd->getDevice(),
@ -285,18 +285,18 @@ $utopia->get('/v1/users/:userId/logs')
function ($userId) use ($response, $register, $projectDB, $project) {
$user = $projectDB->getDocument($userId);
if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
throw new Exception('User not found', 404);
}
$adapter = new AuditAdapter($register->get('db'));
$adapter->setNamespace('app_'.$project->getUid());
$adapter->setNamespace('app_'.$project->getId());
$audit = new Audit($adapter);
$countries = Locale::getText('countries');
$logs = $audit->getLogsByUser($user->getUid());
$logs = $audit->getLogsByUser($user->getId());
$reader = new Reader(__DIR__.'/../../db/DBIP/dbip-country-lite-2020-01.mmdb');
$output = [];
@ -350,7 +350,7 @@ $utopia->patch('/v1/users/:userId/status')
function ($userId, $status) use ($response, $projectDB, $providers) {
$user = $projectDB->getDocument($userId);
if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
throw new Exception('User not found', 404);
}
@ -375,7 +375,7 @@ $utopia->patch('/v1/users/:userId/status')
$response
->json(array_merge($user->getArrayCopy(array_merge([
'$uid',
'$id',
'status',
'email',
'registration',
@ -398,7 +398,7 @@ $utopia->patch('/v1/users/:userId/prefs')
function ($userId, $prefs) use ($response, $projectDB, $providers) {
$user = $projectDB->getDocument($userId);
if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
throw new Exception('User not found', 404);
}
@ -441,15 +441,15 @@ $utopia->delete('/v1/users/:userId/sessions/:session')
function ($userId, $sessionId) use ($response, $request, $projectDB) {
$user = $projectDB->getDocument($userId);
if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
throw new Exception('User not found', 404);
}
$tokens = $user->getAttribute('tokens', []);
foreach ($tokens as $token) { /* @var $token Document */
if ($sessionId == $token->getUid()) {
if (!$projectDB->deleteDocument($token->getUid())) {
if ($sessionId == $token->getId()) {
if (!$projectDB->deleteDocument($token->getId())) {
throw new Exception('Failed to remove token from DB', 500);
}
}
@ -472,14 +472,14 @@ $utopia->delete('/v1/users/:userId/sessions')
function ($userId) use ($response, $request, $projectDB) {
$user = $projectDB->getDocument($userId);
if (empty($user->getUid()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
if (empty($user->getId()) || Database::SYSTEM_COLLECTION_USERS != $user->getCollection()) {
throw new Exception('User not found', 404);
}
$tokens = $user->getAttribute('tokens', []);
foreach ($tokens as $token) { /* @var $token Document */
if (!$projectDB->deleteDocument($token->getUid())) {
if (!$projectDB->deleteDocument($token->getId())) {
throw new Exception('Failed to remove token from DB', 500);
}
}

View file

@ -16,9 +16,9 @@ $utopia->init(function () use ($utopia, $request, $response, $register, $user, $
$timeLimit = new TimeLimit($route->getLabel('abuse-key', 'url:{url},ip:{ip}'), $route->getLabel('abuse-limit', 0), $route->getLabel('abuse-time', 3600), function () use ($register) {
return $register->get('db');
});
$timeLimit->setNamespace('app_'.$project->getUid());
$timeLimit->setNamespace('app_'.$project->getId());
$timeLimit
->setParam('{userId}', $user->getUid())
->setParam('{userId}', $user->getId())
->setParam('{userAgent}', $request->getServer('HTTP_USER_AGENT', ''))
->setParam('{ip}', $request->getIP())
->setParam('{url}', $request->getServer('HTTP_HOST', '').$route->getURL())

View file

@ -183,7 +183,7 @@ $utopia->get('/console/database/collection')
->action(function ($id) use ($layout, $projectDB) {
$collection = $projectDB->getDocument($id, false);
if (empty($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
if (empty($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
throw new Exception('Collection not found', 404);
}

View file

@ -220,10 +220,10 @@ $console = $consoleDB->getDocument('console');
$mode = $request->getParam('mode', $request->getHeader('X-Appwrite-Mode', 'default'));
Auth::setCookieName('a_session_'.$project->getUid());
Auth::setCookieName('a_session_'.$project->getId());
if (APP_MODE_ADMIN === $mode) {
Auth::setCookieName('a_session_'.$console->getUid());
Auth::setCookieName('a_session_'.$console->getId());
}
$session = Auth::decodeSession(
@ -235,7 +235,7 @@ Auth::$secret = $session['secret'];
$projectDB = new Database();
$projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
$projectDB->setNamespace('app_'.$project->getUid());
$projectDB->setNamespace('app_'.$project->getId());
$projectDB->setMocks($collections);
$user = $projectDB->getDocument(Auth::$unique);
@ -244,21 +244,21 @@ if (APP_MODE_ADMIN === $mode) {
$user = $consoleDB->getDocument(Auth::$unique);
$user
->setAttribute('$uid', 'admin-'.$user->getAttribute('$uid'))
->setAttribute('$id', 'admin-'.$user->getAttribute('$id'))
;
}
if (empty($user->getUid()) // Check a document has been found in the DB
if (empty($user->getId()) // Check a document has been found in the DB
|| Database::SYSTEM_COLLECTION_USERS !== $user->getCollection() // Validate returned document is really a user document
|| !Auth::tokenVerify($user->getAttribute('tokens', []), Auth::TOKEN_TYPE_LOGIN, Auth::$secret)) { // Validate user has valid login token
$user = new Document(['$uid' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]);
$user = new Document(['$id' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]);
}
if (APP_MODE_ADMIN === $mode) {
if (!empty($user->search('teamId', $project->getAttribute('teamId'), $user->getAttribute('memberships')))) {
Authorization::disable();
} else {
$user = new Document(['$uid' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]);
$user = new Document(['$id' => '', '$collection' => Database::SYSTEM_COLLECTION_USERS]);
}
}
@ -266,7 +266,7 @@ if (APP_MODE_ADMIN === $mode) {
$register->get('smtp')
->setFrom(
$request->getServer('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM),
($project->getUid() === 'console')
($project->getId() === 'console')
? urldecode($request->getServer('_APP_SYSTEM_EMAIL_NAME', APP_NAME.' Server'))
: sprintf(Locale::getText('account.emails.team'), $project->getAttribute('name')
)

1201
app/tasks/logs.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -3,9 +3,10 @@
require_once __DIR__.'/../init.php';
global $register, $projectDB, $console;
global $register, $projectDB, $console, $providers;
use Database\Database;
use Database\Document;
use Database\Validator\Authorization;
use Utopia\CLI\CLI;
use Utopia\CLI\Console;
@ -19,65 +20,147 @@ $callbacks = [
},
'0.5.0' => function($project) use ($db, $projectDB) {
Console::info('Altering table for project: '.$project->getUid());
Console::info('Upgrading project: '.$project->getId());
try {
$statement = $db->prepare("
ALTER TABLE `appwrite`.`app_{$project->getUid()}.audit.audit` DROP COLUMN IF EXISTS `userType`;
ALTER TABLE `appwrite`.`app_{$project->getUid()}.audit.audit` DROP INDEX IF EXISTS `index_1`;
ALTER TABLE `appwrite`.`app_{$project->getUid()}.audit.audit` ADD INDEX IF NOT EXISTS `index_1` (`userId` ASC);
");
$statement->execute();
}
catch (\Exception $e) {
Console::error($e->getMessage().'/');
}
$statement->closeCursor();
// Update all documents $uid -> $id
$limit = 30;
$sum = 30;
$offset = 0;
while ($sum >= 30) {
$users = $projectDB->getCollection([
$all = $projectDB->getCollection([
'limit' => $limit,
'offset' => $offset,
'orderField' => 'name',
'orderType' => 'ASC',
'orderField' => '$uid',
'orderType' => 'DESC',
'orderCast' => 'string',
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_USERS,
],
]);
$sum = count($users);
$sum = count($all);
Console::success('Fetched '.$sum.' users...');
foreach($users as $user) {
$user
->setAttribute('emailVerification', $user->getAttribute('confirm', false))
->removeAttribute('confirm')
;
if(!$projectDB->updateDocument($user->getArrayCopy())) {
Console::error('Failed to update user');
Console::success('Fetched '.$sum.' (offset: '.$offset.' / limit: '.$limit.') documents from a total of '.$projectDB->getSum());
foreach($all as $document) {
if(empty($document->getAttribute('$uid', null))) {
Console::info('Skipped document');
continue;
}
else {
Console::success('Updated user succefully');
$document = fixDocument($document);
if(empty($document->getId())) {
throw new Exception('Missing ID');
}
try {
$new = $projectDB->overwriteDocument($document->getArrayCopy());
Console::success('Updated document succefully');
} catch (\Throwable $th) {
Console::error('Failed to update document: '.$th->getMessage());
continue;
}
if($new->getId() !== $document->getId()) {
throw new Exception('Duplication Error');
}
}
$offset = $offset + $limit;
}
try {
$statement = $db->prepare("
ALTER TABLE `appwrite`.`app_{$project->getId()}.audit.audit` DROP COLUMN IF EXISTS `userType`;
ALTER TABLE `appwrite`.`app_{$project->getId()}.audit.audit` DROP INDEX IF EXISTS `index_1`;
ALTER TABLE `appwrite`.`app_{$project->getId()}.audit.audit` ADD INDEX IF NOT EXISTS `index_1` (`userId` ASC);
");
$statement->closeCursor();
$statement->execute();
}
catch (\Exception $e) {
Console::error('Failed to alter table for project: '.$project->getId().' with message: '.$e->getMessage().'/');
}
},
];
function fixDocument(Document $document) {
global $providers;
if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_PROJECTS){
foreach($providers as $key => $provider) {
if(!empty($document->getAttribute('usersOauth'.ucfirst($key).'Appid'))) {
$document
->setAttribute('usersOauth2'.ucfirst($key).'Appid', $document->getAttribute('usersOauth'.ucfirst($key).'Appid', ''))
->removeAttribute('usersOauth'.ucfirst($key).'Appid')
;
}
if(!empty($document->getAttribute('usersOauth'.ucfirst($key).'Secret'))) {
$document
->setAttribute('usersOauth2'.ucfirst($key).'Secret', $document->getAttribute('usersOauth'.ucfirst($key).'Secret', ''))
->removeAttribute('usersOauth'.ucfirst($key).'Secret')
;
}
}
}
if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_USERS) {
foreach($providers as $key => $provider) {
if(!empty($document->getAttribute('oauth'.ucfirst($key)))) {
$document
->setAttribute('oauth2'.ucfirst($key), $document->getAttribute('oauth'.ucfirst($key), ''))
->removeAttribute('oauth'.ucfirst($key))
;
}
if(!empty($document->getAttribute('oauth'.ucfirst($key).'AccessToken'))) {
$document
->setAttribute('oauth2'.ucfirst($key).'AccessToken', $document->getAttribute('oauth'.ucfirst($key).'AccessToken', ''))
->removeAttribute('oauth'.ucfirst($key).'AccessToken')
;
}
}
if($document->getAttribute('confirm', null) !== null) {
$document
->setAttribute('emailVerification', $document->getAttribute('confirm', $document->getAttribute('emailVerification', false)))
->removeAttribute('confirm')
;
}
}
if(empty($document->getAttribute('$uid', null))) {
return $document;
}
$document
->setAttribute('$id', $document->getAttribute('$uid', null))
->removeAttribute('$uid')
;
foreach($document as &$attr) {
if($attr instanceof Document) {
$attr = fixDocument($attr);
}
if(is_array($attr)) {
foreach($attr as &$child) {
if($child instanceof Document) {
$child = fixDocument($child);
}
}
}
}
return $document;
}
$cli
->task('run')
->action(function () use ($console, $db, $projectDB, $consoleDB, $callbacks) {
->action(function () use ($console, $projectDB, $consoleDB, $callbacks) {
Console::success('Starting Upgrade');
Authorization::disable();
@ -89,9 +172,15 @@ $cli
while ($sum >= 30) {
foreach($projects as $project) {
$projectDB->setNamespace('app_'.$project->getUid());
$projectDB->setNamespace('app_'.$project->getId());
$callbacks['0.5.0']($project);
try {
$callbacks['0.5.0']($project);
} catch (\Throwable $th) {
Console::error('Failed to update project ("'.$project->getId().'") version with error: '.$th->getMessage());
$projectDB->setNamespace('app_console');
$projectDB->deleteDocument($project->getId());
}
}
$projects = $consoleDB->getCollection([

View file

@ -213,7 +213,7 @@
data-failure-param-alert-text="Logout from Session Failed"
data-failure-param-alert-classname="error">
<input type="hidden" name="sessionId" data-ls-bind="{{session.$uid}}">
<input type="hidden" name="sessionId" data-ls-bind="{{session.$id}}">
<button class="danger">Logout</button>
</form>
</span>
@ -234,7 +234,7 @@
data-failure="alert"
data-failure-param-alert-text="Logout from Session Failed"
data-failure-param-alert-classname="error">
<input type="hidden" name="sessionId" data-ls-bind="{{session.$uid}}">
<input type="hidden" name="sessionId" data-ls-bind="{{session.$id}}">
<button class="danger">Logout</button>
</form>
</span>

View file

@ -10,7 +10,7 @@
data-ls-bind="{{router.params.project}}"
data-unsync="1"
data-ls-loop="projects" data-ls-as="option">
<option data-ls-attrs="value={{option.$uid}}" data-ls-bind="{{option.name}}"></option>
<option data-ls-attrs="value={{option.$id}}" data-ls-bind="{{option.name}}"></option>
</select>
</label>
</div>

View file

@ -67,7 +67,7 @@
<div data-ls-if="0 != {{project-collections.sum}}">
<ul data-ls-loop="project-collections.collections" data-ls-as="collection" class="items">
<li data-ls-attrs="class={{collection.$uid|selectedCollection}},data-uid={{router.params.collectionId}}">
<li data-ls-attrs="class={{collection.$id|selectedCollection}},data-uid={{router.params.collectionId}}">
<form
data-service="database.listDocuments"
data-event="submit"
@ -79,8 +79,8 @@
data-name="project-documents"
data-success="state"
data-success-param-state-keys="collectionId=collectionId,search=dsearch,offset=doffset">
<input name="collectionId" data-ls-bind="{{collection.$uid}}" type="hidden" />
<button><span data-ls-bind="{{collection.$uid}}"></span></button>
<input name="collectionId" data-ls-bind="{{collection.$id}}" type="hidden" />
<button><span data-ls-bind="{{collection.$id}}"></span></button>
</form>
<i class="icon-right-open pull-end"></i>
@ -165,7 +165,7 @@
<div data-ls-if="0 != {{project-documents.sum}}">
<ul data-ls-loop="project-documents.documents" data-ls-as="node" class="items">
<li data-ls-attrs="class={{node.$uid|selectedDocument}},data-uid={{router.params.documentId}}">
<li data-ls-attrs="class={{node.$id|selectedDocument}},data-uid={{router.params.documentId}}">
<form
data-service="database.getDocument"
data-event="submit"
@ -174,12 +174,12 @@
data-success="state"
data-success-param-state-keys="documentId=documentId">
<input name="collectionId" data-ls-bind="{{router.params.collectionId}}" type="hidden" />
<input name="documentId" data-ls-bind="{{node.$uid}}" type="hidden" />
<button><span data-ls-bind="{{node.$uid}}"></span></button>
<input name="documentId" data-ls-bind="{{node.$id}}" type="hidden" />
<button><span data-ls-bind="{{node.$id}}"></span></button>
</form>
<i class="icon-right-open pull-end"></i>
<span data-ls-bind="{{node.$uid}}"></span>
<span data-ls-bind="{{node.$id}}"></span>
</li>
</ul>
</div>
@ -222,7 +222,7 @@
</div>
<div class="col span-6">
<h3>
<b data-ls-if="({{project-document.$uid}})">Preview</b>
<b data-ls-if="({{project-document.$id}})">Preview</b>
</h3>
<div
@ -236,7 +236,7 @@
data-success-param-state-keys="documentId=documentId">
</div>
<div data-ls-if="({{project-document.$uid}})" style="display: none">
<div data-ls-if="({{project-document.$id}})" style="display: none">
<div class="code">
<input type="hidden" data-forms-code data-ls-bind="{{project-document}}" />

View file

@ -110,7 +110,7 @@ $graph = $this->getParam('graph', false);
data-failure-param-alert-text="Failed to delete platform"
data-failure-param-alert-classname="error">
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<input type="hidden" name="platformId" data-ls-bind="{{platform.$uid}}" />
<input type="hidden" name="platformId" data-ls-bind="{{platform.$id}}" />
<button class="reverse danger">Delete</button>
</form>
@ -211,10 +211,10 @@ $graph = $this->getParam('graph', false);
data-failure-param-alert-classname="error">
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}"/ >
<input type="hidden" name="platformId" data-ls-bind="{{platform.$uid}}" />
<input type="hidden" name="platformId" data-ls-bind="{{platform.$id}}" />
<label data-ls-attrs="for=name-{{platform.$uid}}">Name <span class="tooltip large" data-tooltip="Choose any name that will help you distinguish between your different apps."><i class="icon-question"></i></span></label>
<input type="text" class="full-width" data-ls-attrs="id=name-{{platform.$uid}}" name="name" required autocomplete="off" data-ls-bind="{{platform.name}}" />
<label data-ls-attrs="for=name-{{platform.$id}}">Name <span class="tooltip large" data-tooltip="Choose any name that will help you distinguish between your different apps."><i class="icon-question"></i></span></label>
<input type="text" class="full-width" data-ls-attrs="id=name-{{platform.$id}}" name="name" required autocomplete="off" data-ls-bind="{{platform.name}}" />
<label for="url">URL <span class="tooltip large" data-tooltip="The URL that your website will use to interact with the <?php echo APP_NAME; ?> APIs in production or development environments."><i class="icon-question"></i></span></label>
<input name="url" type="url" class="margin-bottom" autocomplete="off" placeholder="example.com" data-ls-bind="{{platform.url}}" required>

View file

@ -39,7 +39,7 @@ $home = $this->getParam('home', '');
<ul data-ls-loop="console-projects" data-ls-as="project" data-ls-append="" class="tiles cell-3" style="visibility: hidden">
<li class="margin-bottom">
<a data-ls-attrs="href=/console/home?project={{project.$uid}}" class="box">
<a data-ls-attrs="href=/console/home?project={{project.$id}}" class="box">
<div data-ls-bind="{{project.name}}" class="text-one-liner margin-bottom-large text-bold">&nbsp;</div>
<i class="icon-right-open"></i>

View file

@ -44,12 +44,12 @@ $scopes = $this->getParam('scopes', []);
data-failure-param-alert-classname="error">
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<input type="hidden" name="keyId" data-ls-bind="{{key.$uid}}" />
<input type="hidden" name="keyId" data-ls-bind="{{key.$id}}" />
<label data-ls-attrs="for=name-{{key.$uid}}">Name</label>
<input type="text" class="full-width" data-ls-attrs="id=name-{{key.$uid}}" name="name" required autocomplete="off" data-ls-bind="{{key.name}}" />
<label data-ls-attrs="for=name-{{key.$id}}">Name</label>
<input type="text" class="full-width" data-ls-attrs="id=name-{{key.$id}}" name="name" required autocomplete="off" data-ls-bind="{{key.name}}" />
<label data-ls-attrs="for=scopes-{{key.$uid}}">Scopes (<a href="/docs/keys" target="_blank">Learn More</a>)</label>
<label data-ls-attrs="for=scopes-{{key.$id}}">Scopes (<a href="/docs/keys" target="_blank">Learn More</a>)</label>
<div class="row thin margin-bottom">
<?php foreach ($scopes as $i => $scope) : ?>
<div class="col span-6">
@ -85,7 +85,7 @@ $scopes = $this->getParam('scopes', []);
data-failure-param-alert-classname="error">
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<input type="hidden" name="keyId" data-ls-bind="{{key.$uid}}" />
<input type="hidden" name="keyId" data-ls-bind="{{key.$id}}" />
<button class="reverse danger">Delete</button>
</form>

View file

@ -33,7 +33,7 @@
data-failure-param-alert-text="Failed to update project"
data-failure-param-alert-classname="error">
<input name="$uid" type="hidden" data-ls-bind="{{console-project.$uid}}" />
<input name="$id" type="hidden" data-ls-bind="{{console-project.$id}}" />
<div class="row">
<div class="col span-9">
@ -41,9 +41,9 @@
<label for="name">Name</label>
<input name="name" id="name" type="text" autocomplete="off" data-ls-bind="{{console-project.name}}" data-forms-text-direction required>
<label for="name">Project UID</label>
<label for="name">Project ID</label>
<div class="input-copy">
<input data-forms-copy type="text" disabled data-ls-bind="{{console-project.$uid}}" />
<input data-forms-copy type="text" disabled data-ls-bind="{{console-project.$id}}" />
</div>
<label for="name">API Endpoint</label>
@ -89,7 +89,7 @@
<h2>Privacy & Legal</h2>
<div class="box margin-bottom">
<input name="$uid" type="hidden" data-ls-bind="{{console-project.$uid}}" />
<input name="$id" type="hidden" data-ls-bind="{{console-project.$id}}" />
<div class="row thin">
<div class="col span-6">
@ -153,7 +153,7 @@
data-failure-param-alert-classname="error">
<input name="teamId" id="teamId" type="hidden" data-ls-bind="{{console-project.teamId}}">
<input name="inviteId" id="inviteId" type="hidden" data-ls-bind="{{member.$uid}}">
<input name="inviteId" id="inviteId" type="hidden" data-ls-bind="{{member.$id}}">
<button class="danger">Leave</button>
</form>
@ -173,7 +173,7 @@
data-failure-param-alert-classname="error">
<input name="teamId" id="teamId" type="hidden" data-ls-bind="{{console-project.teamId}}">
<input name="inviteId" id="inviteId" type="hidden" data-ls-bind="{{member.$uid}}">
<input name="inviteId" id="inviteId" type="hidden" data-ls-bind="{{member.$id}}">
<button class="reverse">Resend</button>
</form>

View file

@ -102,7 +102,7 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0);
<tbody data-ls-loop="project-files.files" data-ls-as="file">
<tr>
<td class="hide">
<img src="" data-ls-attrs="src=//{{env.DOMAIN}}/v1/storage/files/{{file.$uid}}/preview?width=45&height=45&project={{router.params.project}}&mode=admin" class="pull-start avatar" loading="lazy" width="30" height="30" />
<img src="" data-ls-attrs="src=//{{env.DOMAIN}}/v1/storage/files/{{file.$id}}/preview?width=45&height=45&project={{router.params.project}}&mode=admin" class="pull-start avatar" loading="lazy" width="30" height="30" />
</td>
<td data-title="Name: ">
<div data-ui-modal class="box modal close" data-button-text="{{file.name}}" data-button-class="link">
@ -124,9 +124,9 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0);
data-failure-param-alert-text="Failed to update file"
data-failure-param-alert-classname="error">
<label for="files-fileId">File UID</label>
<label for="files-fileId">File ID</label>
<div class="input-copy">
<input data-forms-copy type="text" name="fileId" id="files-fileId" disabled data-ls-bind="{{file.$uid}}" />
<input data-forms-copy type="text" name="fileId" id="files-fileId" disabled data-ls-bind="{{file.$id}}" />
</div>
<input type="hidden" name="folderId" id="files-folderId" data-cast-to="int" value="1">
@ -139,7 +139,7 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0);
<hr />
<div class="pull-end">
<a href="" data-ls-attrs="href=//{{env.DOMAIN}}/v1/storage/files/{{file.$uid}}/preview?project={{router.params.project}}&mode=admin" target="_blank">Open preview <i class="icon-link-ext"></i></a>
<a href="" data-ls-attrs="href=//{{env.DOMAIN}}/v1/storage/files/{{file.$id}}/preview?project={{router.params.project}}&mode=admin" target="_blank">Open preview <i class="icon-link-ext"></i></a>
</div>
<button type="submit">Update</button> &nbsp; <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>

View file

@ -89,25 +89,25 @@
data-failure-param-alert-classname="error">
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<input type="hidden" name="taskId" data-ls-bind="{{task.$uid}}" />
<input type="hidden" name="taskId" data-ls-bind="{{task.$id}}" />
<label data-ls-attrs="for=name-{{task.$uid}}">Name</label>
<input type="text" class="full-width" data-ls-attrs="id=name-{{task.$uid}}" name="name" required autocomplete="off" data-ls-bind="{{task.name}}" />
<label data-ls-attrs="for=name-{{task.$id}}">Name</label>
<input type="text" class="full-width" data-ls-attrs="id=name-{{task.$id}}" name="name" required autocomplete="off" data-ls-bind="{{task.name}}" />
<label data-ls-attrs="for=status-{{task.$uid}}" class="margin-bottom">Status
<label data-ls-attrs="for=status-{{task.$id}}" class="margin-bottom">Status
<div class="margin-top-small">
<input name="status" type="radio" checked="checked" required data-ls-bind="{{task.status}}" value="play" /> &nbsp; <span>Play</span>
<input name="status" type="radio" required data-ls-bind="{{task.status}}" value="pause" /> &nbsp; <span>Pause</span>
</div>
</label>
<label data-ls-attrs="for=schedule-{{task.$uid}}">Schedule (CRON Syntax)</label>
<input type="text" class="full-width" data-ls-attrs="id=schedule-{{task.$uid}}" name="schedule" required autocomplete="off" data-ls-bind="{{task.schedule}}" placeholder="* * * * *" />
<label data-ls-attrs="for=schedule-{{task.$id}}">Schedule (CRON Syntax)</label>
<input type="text" class="full-width" data-ls-attrs="id=schedule-{{task.$id}}" name="schedule" required autocomplete="off" data-ls-bind="{{task.schedule}}" placeholder="* * * * *" />
<div class="row thin">
<div class="col span-4">
<label data-ls-attrs="for=httpMethod-{{task.$uid}}">HTTP Method</label>
<select data-ls-attrs="id=httpMethod-{{task.$uid}}" name="httpMethod" required data-ls-bind="{{task.httpMethod}}">
<label data-ls-attrs="for=httpMethod-{{task.$id}}">HTTP Method</label>
<select data-ls-attrs="id=httpMethod-{{task.$id}}" name="httpMethod" required data-ls-bind="{{task.httpMethod}}">
<option value="POST">POST</option>
<option value="GET">GET</option>
<option value="PUT">PUT</option>
@ -120,8 +120,8 @@
</select>
</div>
<div class="col span-8">
<label data-ls-attrs="for=httpUrl-{{task.$uid}}">HTTP URL</label>
<input type="url" class="full-width" data-ls-attrs="id=httpUrl-{{task.$uid}}" name="httpUrl" required autocomplete="off" placeholder="https://example.com/callback" data-ls-bind="{{task.httpUrl}}" />
<label data-ls-attrs="for=httpUrl-{{task.$id}}">HTTP URL</label>
<input type="url" class="full-width" data-ls-attrs="id=httpUrl-{{task.$id}}" name="httpUrl" required autocomplete="off" placeholder="https://example.com/callback" data-ls-bind="{{task.httpUrl}}" />
</div>
</div>
@ -166,7 +166,7 @@
</div>
</div>
<label data-ls-attrs="for=security-{{task.$uid}}" class="margin-bottom">
<label data-ls-attrs="for=security-{{task.$id}}" class="margin-bottom">
<div class="margin-bottom-small text-bold">SSL / TLS (Certificate verification)</div>
<input name="security" type="radio" required data-ls-bind="{{task.security}}" value="1" /> &nbsp; <span>Enabled</span>
@ -181,12 +181,12 @@
<div class="row thin">
<div class="col span-6">
<label data-ls-attrs="for=httpUser-{{task.$uid}}">User</label>
<input type="text" class="full-width margin-bottom-no" data-ls-attrs="id=httpUser-{{task.$uid}}" name="httpUser" autocomplete="off" data-ls-bind="{{task.httpUser}}" />
<label data-ls-attrs="for=httpUser-{{task.$id}}">User</label>
<input type="text" class="full-width margin-bottom-no" data-ls-attrs="id=httpUser-{{task.$id}}" name="httpUser" autocomplete="off" data-ls-bind="{{task.httpUser}}" />
</div>
<div class="col span-6">
<label data-ls-attrs="for=httpPass-{{task.$uid}}">Password</label>
<input type="password" class="full-width margin-bottom-no" data-ls-attrs="id=httpPass-{{task.$uid}}" name="httpPass" autocomplete="off" data-ls-bind="{{task.httpPass}}" />
<label data-ls-attrs="for=httpPass-{{task.$id}}">Password</label>
<input type="password" class="full-width margin-bottom-no" data-ls-attrs="id=httpPass-{{task.$id}}" name="httpPass" autocomplete="off" data-ls-bind="{{task.httpPass}}" />
</div>
</div>
</div>
@ -210,7 +210,7 @@
data-failure-param-alert-classname="error">
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<input type="hidden" name="taskId" data-ls-bind="{{task.$uid}}" />
<input type="hidden" name="taskId" data-ls-bind="{{task.$id}}" />
<button class="danger fill">Delete</button>
</form>

View file

@ -104,7 +104,7 @@ $providers = $this->getParam('providers', []);
<img src="" data-ls-attrs="src={{user|gravatar}}" data-size="45" alt="User Avatar" class="avatar pull-start" loading="lazy" width="30" height="30" />
</td>
<td data-title="Name: ">
<a data-ls-attrs="href=/console/users/view?id={{user.$uid}}&project={{router.params.project}}">
<a data-ls-attrs="href=/console/users/view?id={{user.$id}}&project={{router.params.project}}">
<span data-ls-bind="{{user.name}}"></span>
<span data-ls-if="{{user.name}} === ''">-----</span>
</a>
@ -265,13 +265,13 @@ $providers = $this->getParam('providers', []);
data-failure-param-alert-text="Failed to update team"
data-failure-param-alert-classname="error">
<label for="name">UID</label>
<label for="name">ID</label>
<div class="input-copy">
<input name="teamId" data-forms-copy type="text" disabled data-ls-bind="{{team.$uid}}" />
<input name="teamId" data-forms-copy type="text" disabled data-ls-bind="{{team.$id}}" />
</div>
<label for="name">Name</label>
<input name="name" data-ls-attrs="id=name-{{team.$uid}}" type="text" autocomplete="off" data-ls-bind="{{team.name}}">
<input name="name" data-ls-attrs="id=name-{{team.$id}}" type="text" autocomplete="off" data-ls-bind="{{team.name}}">
<button>Update</button> &nbsp; <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
</form>

View file

@ -82,7 +82,7 @@
<div class="col span-4">
<label>User ID</label>
<div class="input-copy margin-bottom-large">
<input id="uid" type="text" autocomplete="off" placeholder="" data-ls-bind="{{user.$uid}}" disabled data-forms-copy>
<input id="uid" type="text" autocomplete="off" placeholder="" data-ls-bind="{{user.$id}}" disabled data-forms-copy>
</div>
<div data-ls-if="{{user.status}} !== <?php echo \Auth\Auth::USER_STATUS_BLOCKED; ?>" style="display: none">

View file

@ -68,12 +68,12 @@ $events = [
data-failure-param-alert-classname="error">
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<input type="hidden" name="webhookId" data-ls-bind="{{webhook.$uid}}" />
<input type="hidden" name="webhookId" data-ls-bind="{{webhook.$id}}" />
<label data-ls-attrs="for=name-{{webhook.$uid}}">Name</label>
<input type="text" class="full-width" data-ls-attrs="id=name-{{webhook.$uid}}" name="name" required autocomplete="off" data-ls-bind="{{webhook.name}}" />
<label data-ls-attrs="for=name-{{webhook.$id}}">Name</label>
<input type="text" class="full-width" data-ls-attrs="id=name-{{webhook.$id}}" name="name" required autocomplete="off" data-ls-bind="{{webhook.name}}" />
<label data-ls-attrs="for=events-{{webhook.$uid}}">Events</label>
<label data-ls-attrs="for=events-{{webhook.$id}}">Events</label>
<div class="row thin margin-bottom">
<?php foreach ($events as $i => $event) : ?>
<div class="col span-6">
@ -87,8 +87,8 @@ $events = [
<?php endforeach; ?>
</div>
<label data-ls-attrs="for=url-{{webhook.$uid}}">POST URL</label>
<input type="url" class="full-width" data-ls-attrs="id=url-{{webhook.$uid}}" name="url" required autocomplete="off" placeholder="https://example.com/callback" data-ls-bind="{{webhook.url}}" />
<label data-ls-attrs="for=url-{{webhook.$id}}">POST URL</label>
<input type="url" class="full-width" data-ls-attrs="id=url-{{webhook.$id}}" name="url" required autocomplete="off" placeholder="https://example.com/callback" data-ls-bind="{{webhook.url}}" />
<div class="margin-bottom toggle" data-ls-ui-open>
<i class="icon-plus pull-end margin-top-tiny"></i>
@ -99,11 +99,11 @@ $events = [
<small class="text-size-small">(optional)</small>
</h2>
<label data-ls-attrs="for=security-{{task.$uid}}" class="margin-bottom-small">
<label data-ls-attrs="for=security-{{task.$id}}" class="margin-bottom-small">
<div class="margin-bottom-small text-bold">SSL / TLS (Certificate verification)</div>
<input name="security" type="radio" required data-ls-attrs="id=secure-yes-{{webhook.$uid}}" data-ls-bind="{{webhook.security}}" value="1" /> &nbsp; <span>Enabled</span>
<input name="security" type="radio" required data-ls-attrs="id=secure-no-{{webhook.$uid}}" data-ls-bind="{{webhook.security}}" value="0" /> &nbsp; <span>Disabled</span>
<input name="security" type="radio" required data-ls-attrs="id=secure-yes-{{webhook.$id}}" data-ls-bind="{{webhook.security}}" value="1" /> &nbsp; <span>Enabled</span>
<input name="security" type="radio" required data-ls-attrs="id=secure-no-{{webhook.$id}}" data-ls-bind="{{webhook.security}}" value="0" /> &nbsp; <span>Disabled</span>
</label>
<p class="margin-bottom text-size-small text-fade"><span class="text-red">Warning</span>: Untrusted or self-signed certificates may not be secure.
@ -114,12 +114,12 @@ $events = [
<div class="row thin">
<div class="col span-6">
<label data-ls-attrs="for=httpUser-{{webhook.$uid}}">User</label>
<input type="text" class="full-width margin-bottom-no" data-ls-attrs="id=httpUser-{{webhook.$uid}}" name="httpUser" autocomplete="off" data-ls-bind="{{webhook.httpUser}}" />
<label data-ls-attrs="for=httpUser-{{webhook.$id}}">User</label>
<input type="text" class="full-width margin-bottom-no" data-ls-attrs="id=httpUser-{{webhook.$id}}" name="httpUser" autocomplete="off" data-ls-bind="{{webhook.httpUser}}" />
</div>
<div class="col span-6">
<label data-ls-attrs="for=httpPass-{{webhook.$uid}}">Password</label>
<input type="password" class="full-width margin-bottom-no" data-ls-attrs="id=httpPass-{{webhook.$uid}}" name="httpPass" autocomplete="off" data-ls-bind="{{webhook.httpPass}}" />
<label data-ls-attrs="for=httpPass-{{webhook.$id}}">Password</label>
<input type="password" class="full-width margin-bottom-no" data-ls-attrs="id=httpPass-{{webhook.$id}}" name="httpPass" autocomplete="off" data-ls-bind="{{webhook.httpPass}}" />
</div>
</div>
</div>
@ -144,7 +144,7 @@ $events = [
data-failure-param-alert-classname="error">
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
<input type="hidden" name="webhookId" data-ls-bind="{{webhook.$uid}}" />
<input type="hidden" name="webhookId" data-ls-bind="{{webhook.$id}}" />
<button class="danger reverse">Delete</button>
</form>
@ -211,7 +211,7 @@ $events = [
<small class="text-size-small">(optional)</small>
</h2>
<label data-ls-attrs="for=security-{{task.$uid}}" class="margin-bottom-small">
<label data-ls-attrs="for=security-{{task.$id}}" class="margin-bottom-small">
<div class="margin-bottom-small text-bold">SSL / TLS (Certificate verification)</div>
<input name="security" type="radio" required data-ls-attrs="id=secure-yes" checked="checked" value="1" /> &nbsp; <span>Enabled</span>

View file

@ -1,6 +1,6 @@
<div class="logo text-align-center">
<a href="/">
<img src="/images/appwrite.svg" alt="Appwrite Light Logo" class="force-light" />
<img src="/images/appwrite-footer.svg" alt="Appwrite Dark Logo" class="force-dark" />
<img src="/images/appwrite-footer-dark.svg" alt="Appwrite Dark Logo" class="force-dark" />
</a>
</div>

View file

@ -38,7 +38,7 @@ class TasksV1
* If error count bigger than allowed change status to pause
*/
$taskId = (isset($this->args['$uid'])) ? $this->args['$uid'] : null;
$taskId = (isset($this->args['$id'])) ? $this->args['$id'] : null;
$updated = (isset($this->args['updated'])) ? $this->args['updated'] : null;
$next = (isset($this->args['next'])) ? $this->args['next'] : null;
$delay = time() - $next;
@ -58,7 +58,7 @@ class TasksV1
Authorization::enable();
if (is_null($task->getUid()) || Database::SYSTEM_COLLECTION_TASKS !== $task->getCollection()) {
if (is_null($task->getId()) || Database::SYSTEM_COLLECTION_TASKS !== $task->getCollection()) {
throw new Exception('Task Not Found');
}
@ -98,7 +98,7 @@ class TasksV1
$ch,
CURLOPT_HTTPHEADER,
array_merge($headers, [
'X-'.APP_NAME.'-Task-UID: '.$task->getAttribute('$uid', ''),
'X-'.APP_NAME.'-Task-ID: '.$task->getAttribute('$id', ''),
'X-'.APP_NAME.'-Task-Name: '.$task->getAttribute('name', ''),
])
);

View file

@ -36,7 +36,7 @@ class WebhooksV1
Authorization::enable();
if (is_null($project->getUid()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) {
if (is_null($project->getId()) || Database::SYSTEM_COLLECTION_PROJECTS !== $project->getCollection()) {
throw new Exception('Project Not Found');
}

View file

@ -109,7 +109,7 @@ if(read){payload['read']=read;}
if(write){payload['write']=write;}
if(rules){payload['rules']=rules;}
return http.put(path,{'content-type':'application/json',},payload);},deleteCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');}
let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$uid',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');}
let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$id',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');}
let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(filters){payload['filters']=filters;}
if(offset){payload['offset']=offset;}
if(limit){payload['limit']=limit;}
@ -2647,13 +2647,13 @@ var units=si?["KB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB",
var file=document.createElement("li");var image=document.createElement("img");image.src=image.src=env.API+"/storage/files/"+
result+"/preview?width="+
previewWidth+"&height="+
previewHeight+"&project=console";file.className="file avatar";file.tabIndex=0;file.appendChild(image);preview.appendChild(file);var remove=(function(result){return function(event){render(result.$uid);};})(result);file.addEventListener("click",remove);file.addEventListener("keypress",remove);element.value=result;};input.addEventListener("change",function(){var message=alerts.add({text:labelLoading,class:""},0);var files=input.files;var read=JSON.parse(expression.parse(element.dataset["read"]||"[]"));var write=JSON.parse(expression.parse(element.dataset["write"]||"[]"));sdk.storage.createFile(files[0],read,write,1).then(function(response){onComplete(message);render(response.$uid);},function(error){alerts.add({text:"An error occurred!",class:""},3000);onComplete(message);});input.disabled=true;});element.addEventListener("change",function(){console.log('change',element);if(!element.value){return;}
previewHeight+"&project=console";file.className="file avatar";file.tabIndex=0;file.appendChild(image);preview.appendChild(file);var remove=(function(result){return function(event){render(result.$id);};})(result);file.addEventListener("click",remove);file.addEventListener("keypress",remove);element.value=result;};input.addEventListener("change",function(){var message=alerts.add({text:labelLoading,class:""},0);var files=input.files;var read=JSON.parse(expression.parse(element.dataset["read"]||"[]"));var write=JSON.parse(expression.parse(element.dataset["write"]||"[]"));sdk.storage.createFile(files[0],read,write,1).then(function(response){onComplete(message);render(response.$id);},function(error){alerts.add({text:"An error occurred!",class:""},3000);onComplete(message);});input.disabled=true;});element.addEventListener("change",function(){console.log('change',element);if(!element.value){return;}
render(output);});upload.addEventListener("keypress",function(){input.click();});element.parentNode.insertBefore(wrapper,element);wrapper.appendChild(preview);wrapper.appendChild(progress);wrapper.appendChild(upload);upload.appendChild(input);render(output);}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-page-title",repeat:true,controller:function(element,document,expression){document.title=expression.parse(element.getAttribute("data-page-title"))||document.title;}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-scroll-to',repeat:false,controller:function(element,window){let button=window.document.createElement('button');button.className='scroll-to icon-up-dir';button.alt='Back To Top';button.title='Back To Top';button.addEventListener('click',function(){element.scrollIntoView(true,{behavior:'smooth'});button.blur();},false);element.appendChild(button);}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-scroll-direction',repeat:false,controller:function(element,window){let position=0;let check=function(){let direction=window.document.documentElement.scrollTop;if(direction>position){element.classList.remove('scroll-to-top')
element.classList.add('scroll-to-bottom')}
else{element.classList.remove('scroll-to-bottom')
element.classList.add('scroll-to-top')}
position=direction;let current=Math.ceil(direction/window.innerHeight);element.setAttribute('data-views-total',Math.ceil(element.scrollHeight/window.innerHeight));element.setAttribute('data-views-current',current);if(element.scrollHeight<=(direction+element.offsetHeight+300)&&direction>0){element.classList.add('scroll-end')}
else{element.classList.remove('scroll-end')}};window.addEventListener('scroll',check,false);window.addEventListener('resize',check,false);check();}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-setup",controller:function(element,console,form,alerts){element.addEventListener("submit",function(event){event.preventDefault();let loaderId=alerts.add({text:'Creating new project...',class:""},0);let formData=form.toJson(element);formData["name"]=formData["name"]||(element.dataset["defaultName"]||"");console.teams.create(formData["name"]||"").then(function(data){let team=data["$uid"];formData=JSON.parse(JSON.stringify(formData).replace(new RegExp("{{teamId}}","g"),team));console.projects.create(formData["name"],team).then(function(project){alerts.remove(loaderId);window.location.href="/console/home?project="+project["$uid"];},function(){throw new Error("Failed to setup project");});},function(){throw new Error("Setup failed creating project team");});});}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-switch",controller:function(element,router,document){let check=function(c){if(!element.value){return;}
else{element.classList.remove('scroll-end')}};window.addEventListener('scroll',check,false);window.addEventListener('resize',check,false);check();}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-setup",controller:function(element,console,form,alerts){element.addEventListener("submit",function(event){event.preventDefault();let loaderId=alerts.add({text:'Creating new project...',class:""},0);let formData=form.toJson(element);formData["name"]=formData["name"]||(element.dataset["defaultName"]||"");console.teams.create(formData["name"]||"").then(function(data){let team=data["$id"];formData=JSON.parse(JSON.stringify(formData).replace(new RegExp("{{teamId}}","g"),team));console.projects.create(formData["name"],team).then(function(project){alerts.remove(loaderId);window.location.href="/console/home?project="+project["$id"];},function(){throw new Error("Failed to setup project");});},function(){throw new Error("Setup failed creating project team");});});}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-switch",controller:function(element,router,document){let check=function(c){if(!element.value){return;}
if(element.value===router.params.project){return;}
return router.change("/console/home?project="+element.value);};element.addEventListener("change",function(){check();});}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-general-theme",controller:function(element,router,document){let toggle=function(c){if(document.body.classList.contains('theme-light')){document.body.classList.remove('theme-light');document.body.classList.add('theme-dark');window.localStorage.setItem('user-theme','theme-dark')}
else{document.body.classList.remove('theme-dark');document.body.classList.add('theme-light');window.localStorage.setItem('user-theme','theme-light')}};element.addEventListener("click",function(){toggle();});}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-paging-back",controller:function(element,container,expression,env){let paths=[];let limit=env.PAGING_LIMIT;let check=function(){let offset=parseInt(expression.parse(element.dataset["offset"])||"0");paths=paths.concat(expression.getPaths());if(offset-limit<0){element.disabled=true;}else{element.disabled=false;element.value=offset-limit;}};check();for(let i=0;i<paths.length;i++){let path=paths[i].split(".");while(path.length){container.bind(element,path.join("."),check);path.pop();}}}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-paging-next",controller:function(element,container,expression,env){let paths=[];let limit=env.PAGING_LIMIT;let check=function(){let offset=parseInt(expression.parse(element.dataset["offset"])||"0");paths=paths.concat(expression.getPaths());let sum=parseInt(expression.parse(element.dataset["sum"])||"0");paths=paths.concat(expression.getPaths());if(offset+limit>=sum){element.disabled=true;}else{element.disabled=false;element.value=offset+limit;}};check();for(let i=0;i<paths.length;i++){let path=paths[i].split(".");while(path.length){container.bind(element,path.join("."),check);path.pop();}}}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-ui-highlight",controller:function(element,expression,document){let check=function(){let links=element.getElementsByTagName("a");let selected=null;let list=[];for(let i=0;i<links.length;i++){links[i].href=links[i].href||expression.parse(links[i].dataset["lsHref"]||"");list.push(links[i]);}

View file

@ -109,7 +109,7 @@ if(read){payload['read']=read;}
if(write){payload['write']=write;}
if(rules){payload['rules']=rules;}
return http.put(path,{'content-type':'application/json',},payload);},deleteCollection:function(collectionId){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');}
let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$uid',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');}
let path='/database/collections/{collectionId}'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};return http.delete(path,{'content-type':'application/json',},payload);},listDocuments:function(collectionId,filters=[],offset=0,limit=50,orderField='$id',orderType='ASC',orderCast='string',search='',first=0,last=0){if(collectionId===undefined){throw new Error('Missing required parameter: "collectionId"');}
let path='/database/collections/{collectionId}/documents'.replace(new RegExp('{collectionId}','g'),collectionId);let payload={};if(filters){payload['filters']=filters;}
if(offset){payload['offset']=offset;}
if(limit){payload['limit']=limit;}

View file

@ -373,13 +373,13 @@ var units=si?["KB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB",
var file=document.createElement("li");var image=document.createElement("img");image.src=image.src=env.API+"/storage/files/"+
result+"/preview?width="+
previewWidth+"&height="+
previewHeight+"&project=console";file.className="file avatar";file.tabIndex=0;file.appendChild(image);preview.appendChild(file);var remove=(function(result){return function(event){render(result.$uid);};})(result);file.addEventListener("click",remove);file.addEventListener("keypress",remove);element.value=result;};input.addEventListener("change",function(){var message=alerts.add({text:labelLoading,class:""},0);var files=input.files;var read=JSON.parse(expression.parse(element.dataset["read"]||"[]"));var write=JSON.parse(expression.parse(element.dataset["write"]||"[]"));sdk.storage.createFile(files[0],read,write,1).then(function(response){onComplete(message);render(response.$uid);},function(error){alerts.add({text:"An error occurred!",class:""},3000);onComplete(message);});input.disabled=true;});element.addEventListener("change",function(){console.log('change',element);if(!element.value){return;}
previewHeight+"&project=console";file.className="file avatar";file.tabIndex=0;file.appendChild(image);preview.appendChild(file);var remove=(function(result){return function(event){render(result.$id);};})(result);file.addEventListener("click",remove);file.addEventListener("keypress",remove);element.value=result;};input.addEventListener("change",function(){var message=alerts.add({text:labelLoading,class:""},0);var files=input.files;var read=JSON.parse(expression.parse(element.dataset["read"]||"[]"));var write=JSON.parse(expression.parse(element.dataset["write"]||"[]"));sdk.storage.createFile(files[0],read,write,1).then(function(response){onComplete(message);render(response.$id);},function(error){alerts.add({text:"An error occurred!",class:""},3000);onComplete(message);});input.disabled=true;});element.addEventListener("change",function(){console.log('change',element);if(!element.value){return;}
render(output);});upload.addEventListener("keypress",function(){input.click();});element.parentNode.insertBefore(wrapper,element);wrapper.appendChild(preview);wrapper.appendChild(progress);wrapper.appendChild(upload);upload.appendChild(input);render(output);}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-page-title",repeat:true,controller:function(element,document,expression){document.title=expression.parse(element.getAttribute("data-page-title"))||document.title;}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-scroll-to',repeat:false,controller:function(element,window){let button=window.document.createElement('button');button.className='scroll-to icon-up-dir';button.alt='Back To Top';button.title='Back To Top';button.addEventListener('click',function(){element.scrollIntoView(true,{behavior:'smooth'});button.blur();},false);element.appendChild(button);}});})(window);(function(window){"use strict";window.ls.view.add({selector:'data-general-scroll-direction',repeat:false,controller:function(element,window){let position=0;let check=function(){let direction=window.document.documentElement.scrollTop;if(direction>position){element.classList.remove('scroll-to-top')
element.classList.add('scroll-to-bottom')}
else{element.classList.remove('scroll-to-bottom')
element.classList.add('scroll-to-top')}
position=direction;let current=Math.ceil(direction/window.innerHeight);element.setAttribute('data-views-total',Math.ceil(element.scrollHeight/window.innerHeight));element.setAttribute('data-views-current',current);if(element.scrollHeight<=(direction+element.offsetHeight+300)&&direction>0){element.classList.add('scroll-end')}
else{element.classList.remove('scroll-end')}};window.addEventListener('scroll',check,false);window.addEventListener('resize',check,false);check();}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-setup",controller:function(element,console,form,alerts){element.addEventListener("submit",function(event){event.preventDefault();let loaderId=alerts.add({text:'Creating new project...',class:""},0);let formData=form.toJson(element);formData["name"]=formData["name"]||(element.dataset["defaultName"]||"");console.teams.create(formData["name"]||"").then(function(data){let team=data["$uid"];formData=JSON.parse(JSON.stringify(formData).replace(new RegExp("{{teamId}}","g"),team));console.projects.create(formData["name"],team).then(function(project){alerts.remove(loaderId);window.location.href="/console/home?project="+project["$uid"];},function(){throw new Error("Failed to setup project");});},function(){throw new Error("Setup failed creating project team");});});}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-switch",controller:function(element,router,document){let check=function(c){if(!element.value){return;}
else{element.classList.remove('scroll-end')}};window.addEventListener('scroll',check,false);window.addEventListener('resize',check,false);check();}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-setup",controller:function(element,console,form,alerts){element.addEventListener("submit",function(event){event.preventDefault();let loaderId=alerts.add({text:'Creating new project...',class:""},0);let formData=form.toJson(element);formData["name"]=formData["name"]||(element.dataset["defaultName"]||"");console.teams.create(formData["name"]||"").then(function(data){let team=data["$id"];formData=JSON.parse(JSON.stringify(formData).replace(new RegExp("{{teamId}}","g"),team));console.projects.create(formData["name"],team).then(function(project){alerts.remove(loaderId);window.location.href="/console/home?project="+project["$id"];},function(){throw new Error("Failed to setup project");});},function(){throw new Error("Setup failed creating project team");});});}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-switch",controller:function(element,router,document){let check=function(c){if(!element.value){return;}
if(element.value===router.params.project){return;}
return router.change("/console/home?project="+element.value);};element.addEventListener("change",function(){check();});}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-general-theme",controller:function(element,router,document){let toggle=function(c){if(document.body.classList.contains('theme-light')){document.body.classList.remove('theme-light');document.body.classList.add('theme-dark');window.localStorage.setItem('user-theme','theme-dark')}
else{document.body.classList.remove('theme-dark');document.body.classList.add('theme-light');window.localStorage.setItem('user-theme','theme-light')}};element.addEventListener("click",function(){toggle();});}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-paging-back",controller:function(element,container,expression,env){let paths=[];let limit=env.PAGING_LIMIT;let check=function(){let offset=parseInt(expression.parse(element.dataset["offset"])||"0");paths=paths.concat(expression.getPaths());if(offset-limit<0){element.disabled=true;}else{element.disabled=false;element.value=offset-limit;}};check();for(let i=0;i<paths.length;i++){let path=paths[i].split(".");while(path.length){container.bind(element,path.join("."),check);path.pop();}}}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-paging-next",controller:function(element,container,expression,env){let paths=[];let limit=env.PAGING_LIMIT;let check=function(){let offset=parseInt(expression.parse(element.dataset["offset"])||"0");paths=paths.concat(expression.getPaths());let sum=parseInt(expression.parse(element.dataset["sum"])||"0");paths=paths.concat(expression.getPaths());if(offset+limit>=sum){element.disabled=true;}else{element.disabled=false;element.value=offset+limit;}};check();for(let i=0;i<paths.length;i++){let path=paths[i].split(".");while(path.length){container.bind(element,path.join("."),check);path.pop();}}}});})(window);(function(window){window.ls.container.get("view").add({selector:"data-ui-highlight",controller:function(element,expression,document){let check=function(){let links=element.getElementsByTagName("a");let selected=null;let list=[];for(let i=0;i<links.length;i++){links[i].href=links[i].href||expression.parse(links[i].dataset["lsHref"]||"");list.push(links[i]);}

View file

@ -1399,7 +1399,7 @@
* @throws {Error}
* @return {Promise}
*/
listDocuments: function(collectionId, filters = [], offset = 0, limit = 50, orderField = '$uid', orderType = 'ASC', orderCast = 'string', search = '', first = 0, last = 0) {
listDocuments: function(collectionId, filters = [], offset = 0, limit = 50, orderField = '$id', orderType = 'ASC', orderCast = 'string', search = '', first = 0, last = 0) {
if(collectionId === undefined) {
throw new Error('Missing required parameter: "collectionId"');
}

View file

@ -104,7 +104,7 @@
var remove = (function(result) {
return function(event) {
render(result.$uid);
render(result.$id);
};
})(result);
@ -128,7 +128,7 @@
function(response) {
onComplete(message);
render(response.$uid);
render(response.$id);
},
function(error) {
alerts.add({ text: "An error occurred!", class: "" }, 3000); // File(s) uploaded.

View file

@ -14,7 +14,7 @@
console.teams.create(formData["name"] || "").then(
function(data) {
let team = data["$uid"];
let team = data["$id"];
formData = JSON.parse(
JSON.stringify(formData).replace(
@ -27,7 +27,7 @@
function(project) {
//router.change();
alerts.remove(loaderId);
window.location.href = "/console/home?project=" + project["$uid"];
window.location.href = "/console/home?project=" + project["$id"];
},
function() {
throw new Error("Failed to setup project");

View file

@ -200,7 +200,7 @@ class Auth
$token['type'] == $type &&
$token['secret'] === self::hash($secret) &&
$token['expire'] >= time()) {
return $token->getUid();
return $token->getId();
}
}

View file

@ -23,7 +23,7 @@ class MySQL extends Adapter
const OPTIONS_LIMIT_ATTRIBUTES = 1000;
/**
* @var PDO
* @var Registry
*/
protected $register;
@ -110,7 +110,7 @@ class MySQL extends Adapter
$properties = $st->fetchAll();
$output = [
'$uid' => null,
'$id' => null,
'$collection' => null,
'$permissions' => (!empty($document['permissions'])) ? json_decode($document['permissions'], true) : [],
];
@ -153,7 +153,7 @@ class MySQL extends Adapter
public function createDocument(array $data = [])
{
$order = 0;
$data = array_merge(['$uid' => null, '$permissions' => []], $data); // Merge data with default params
$data = array_merge(['$id' => null, '$permissions' => []], $data); // Merge data with default params
$signature = md5(json_encode($data, true));
$revision = uniqid('', true);
@ -161,13 +161,13 @@ class MySQL extends Adapter
* When updating node, check if there are any changes to update
* by comparing data md5 signatures
*/
if (null !== $data['$uid']) {
if (null !== $data['$id']) {
$st = $this->getPDO()->prepare('SELECT signature FROM `'.$this->getNamespace().'.database.documents` a
WHERE a.uid = :uid AND a.status = 0
ORDER BY a.updatedAt DESC LIMIT 1;
');
$st->bindValue(':uid', $data['$uid'], PDO::PARAM_STR);
$st->bindValue(':uid', $data['$id'], PDO::PARAM_STR);
$st->execute();
@ -185,11 +185,11 @@ class MySQL extends Adapter
');
// Adding fields properties
if (null === $data['$uid'] || !isset($data['$uid'])) { // Get new fields UID
$data['$uid'] = $this->getUid();
if (null === $data['$id'] || !isset($data['$id'])) { // Get new fields UID
$data['$id'] = $this->getId();
}
$st1->bindValue(':uid', $data['$uid'], PDO::PARAM_STR);
$st1->bindValue(':uid', $data['$id'], PDO::PARAM_STR);
$st1->bindValue(':revision', $revision, PDO::PARAM_STR);
$st1->bindValue(':signature', $signature, PDO::PARAM_STR);
$st1->bindValue(':createdAt', date('Y-m-d H:i:s', time()), PDO::PARAM_STR);
@ -200,13 +200,13 @@ class MySQL extends Adapter
// Delete old properties
$rms1 = $this->getPDO()->prepare('DELETE FROM `'.$this->getNamespace().'.database.properties` WHERE documentUid = :documentUid AND documentRevision != :documentRevision');
$rms1->bindValue(':documentUid', $data['$uid'], PDO::PARAM_STR);
$rms1->bindValue(':documentUid', $data['$id'], PDO::PARAM_STR);
$rms1->bindValue(':documentRevision', $revision, PDO::PARAM_STR);
$rms1->execute();
// Delete old relationships
$rms2 = $this->getPDO()->prepare('DELETE FROM `'.$this->getNamespace().'.database.relationships` WHERE start = :start AND revision != :revision');
$rms2->bindValue(':start', $data['$uid'], PDO::PARAM_STR);
$rms2->bindValue(':start', $data['$id'], PDO::PARAM_STR);
$rms2->bindValue(':revision', $revision, PDO::PARAM_STR);
$rms2->execute();
@ -243,7 +243,7 @@ class MySQL extends Adapter
$data[$key][$i] = $this->createDocument($child);
$this->createRelationship($revision, $data['$uid'], $data[$key][$i]['$uid'], $key, true, $i);
$this->createRelationship($revision, $data['$id'], $data[$key][$i]['$id'], $key, true, $i);
}
continue;
@ -252,7 +252,7 @@ class MySQL extends Adapter
// Handle relation
if (self::DATA_TYPE_DICTIONARY === $type) {
$value = $this->createDocument($value);
$this->createRelationship($revision, $data['$uid'], $value['$uid'], $key); //xxx
$this->createRelationship($revision, $data['$id'], $value['$id'], $key); //xxx
continue;
}
@ -274,7 +274,7 @@ class MySQL extends Adapter
if (is_array($prop['value'])) {
throw new Exception('Value can\'t be an array: '.json_encode($prop['value']));
}
$st2->bindValue(':documentUid', $data['$uid'], PDO::PARAM_STR);
$st2->bindValue(':documentUid', $data['$id'], PDO::PARAM_STR);
$st2->bindValue(':documentRevision', $revision, PDO::PARAM_STR);
$st2->bindValue(':key', $prop['key'], PDO::PARAM_STR);
@ -287,8 +287,8 @@ class MySQL extends Adapter
}
//TODO remove this dependency (check if related to nested documents)
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$uid'], 0);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$uid'], 0);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$id'], 0);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$id'], 0);
return $data;
}
@ -468,7 +468,7 @@ class MySQL extends Adapter
];
$orderTypeMap = ['DESC', 'ASC'];
$options['orderField'] = (empty($options['orderField'])) ? '$uid' : $options['orderField']; // Set default order field
$options['orderField'] = (empty($options['orderField'])) ? '$id' : $options['orderField']; // Set default order field
$options['orderCast'] = (empty($options['orderCast'])) ? 'string' : $options['orderCast']; // Set default order field
if (!array_key_exists($options['orderCast'], $orderCastMap)) {
@ -570,22 +570,22 @@ class MySQL extends Adapter
// Search
if (!empty($options['search'])) { // Handle free search
// $where[] = "LEFT JOIN `" . $this->getNamespace() . ".database.properties` b_search ON a.uid IS NOT NULL AND b_search.documentUid = a.uid
// LEFT JOIN
// `" . $this->getNamespace() . ".database.relationships` c_search ON c_search.start = a.uid
// LEFT JOIN
// `" . $this->getNamespace() . ".database.properties` d_search ON d_search.documentUid = c_search.end
// LEFT JOIN
// `" . $this->getNamespace() . ".database.relationships` e_search ON e_search.start = c_search.end
// LEFT JOIN
// `" . $this->getNamespace() . ".database.properties` f_search ON f_search.documentUid = e_search.end
// \n";
// $search = "AND (MATCH (b_search.value) AGAINST ({$this->getPDO()->quote($options['search'], PDO::PARAM_STR)} IN BOOLEAN MODE)
// OR b_search.value LIKE {$this->getPDO()->quote('%%' . $options['search'] . '%%', PDO::PARAM_STR)}
// OR MATCH (d_search.value) AGAINST ({$this->getPDO()->quote($options['search'], PDO::PARAM_STR)} IN BOOLEAN MODE)
// OR d_search.value LIKE {$this->getPDO()->quote('%%' . $options['search'] . '%%', PDO::PARAM_STR)}
// OR MATCH (f_search.value) AGAINST ({$this->getPDO()->quote($options['search'], PDO::PARAM_STR)} IN BOOLEAN MODE)
// OR f_search.value LIKE {$this->getPDO()->quote('%%' . $options['search'] . '%%', PDO::PARAM_STR)})";
// $where[] = "LEFT JOIN `" . $this->getNamespace() . ".database.properties` b_search ON a.uid IS NOT NULL AND b_search.documentUid = a.uid
// LEFT JOIN
// `" . $this->getNamespace() . ".database.relationships` c_search ON c_search.start = a.uid
// LEFT JOIN
// `" . $this->getNamespace() . ".database.properties` d_search ON d_search.documentUid = c_search.end
// LEFT JOIN
// `" . $this->getNamespace() . ".database.relationships` e_search ON e_search.start = c_search.end
// LEFT JOIN
// `" . $this->getNamespace() . ".database.properties` f_search ON f_search.documentUid = e_search.end
// \n";
// $search = "AND (MATCH (b_search.value) AGAINST ({$this->getPDO()->quote($options['search'], PDO::PARAM_STR)} IN BOOLEAN MODE)
// OR b_search.value LIKE {$this->getPDO()->quote('%%' . $options['search'] . '%%', PDO::PARAM_STR)}
// OR MATCH (d_search.value) AGAINST ({$this->getPDO()->quote($options['search'], PDO::PARAM_STR)} IN BOOLEAN MODE)
// OR d_search.value LIKE {$this->getPDO()->quote('%%' . $options['search'] . '%%', PDO::PARAM_STR)}
// OR MATCH (f_search.value) AGAINST ({$this->getPDO()->quote($options['search'], PDO::PARAM_STR)} IN BOOLEAN MODE)
// OR f_search.value LIKE {$this->getPDO()->quote('%%' . $options['search'] . '%%', PDO::PARAM_STR)})";
$where[] = 'LEFT JOIN `'.$this->getNamespace().".database.properties` b_search ON a.uid IS NOT NULL AND b_search.documentUid = a.uid AND b_search.primitive = 'string'
LEFT JOIN
@ -749,7 +749,7 @@ class MySQL extends Adapter
/**
* Get Unique Document ID.
*/
public function getUid()
public function getId()
{
$unique = uniqid();
$attempts = 5;
@ -757,7 +757,7 @@ class MySQL extends Adapter
for ($i = 1; $i <= $attempts; ++$i) {
$document = $this->getDocument($unique);
if (empty($document) || $document['$uid'] !== $unique) {
if (empty($document) || $document['$id'] !== $unique) {
return $unique;
}
}

View file

@ -109,8 +109,8 @@ class Redis extends Adapter
{
$data = $this->adapter->createDocument($data);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$uid'], 0);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$uid'], 0);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$id'], 0);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$id'], 0);
return $data;
}
@ -128,8 +128,8 @@ class Redis extends Adapter
{
$data = $this->adapter->updateDocument($data);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$uid'], 0);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$uid'], 0);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$id'], 0);
$this->getRedis()->expire($this->getNamespace().':document-'.$data['$id'], 0);
return $data;
}

View file

@ -125,7 +125,7 @@ class Database
'limit' => 15,
'search' => '',
'relations' => true,
'orderField' => '$uid',
'orderField' => '$id',
'orderType' => 'ASC',
'orderCast' => 'int',
'first' => false,
@ -208,14 +208,14 @@ class Database
*/
public function updateDocument(array $data)
{
if (!isset($data['$uid'])) {
throw new Exception('Must define $uid attribute');
if (!isset($data['$id'])) {
throw new Exception('Must define $id attribute');
}
$document = $this->getDocument($data['$uid']); // TODO make sure user don\'t need read permission for write operations
$document = $this->getDocument($data['$id']); // TODO make sure user don\'t need read permission for write operations
// Make sure reserved keys stay constant
$data['$uid'] = $document->getUid();
$data['$id'] = $document->getId();
$data['$collection'] = $document->getCollection();
$validator = new Authorization($document, 'write');
@ -239,6 +239,42 @@ class Database
return new Document($this->adapter->updateDocument($data));
}
/**
* @param array $data
*
* @return Document|false
*
* @throws Exception
*/
public function overwriteDocument(array $data)
{
if (!isset($data['$id'])) {
throw new Exception('Must define $id attribute');
}
$document = $this->getDocument($data['$id']); // TODO make sure user don\'t need read permission for write operations
$validator = new Authorization($document, 'write');
if (!$validator->isValid($document->getPermissions())) { // Check if user has write access to this document
throw new AuthorizationException($validator->getDescription()); // var_dump($validator->getDescription()); return false;
}
$new = new Document($data);
if (!$validator->isValid($new->getPermissions())) { // Check if user has write access to this document
throw new AuthorizationException($validator->getDescription()); // var_dump($validator->getDescription()); return false;
}
$validator = new Structure($this);
if (!$validator->isValid($new)) { // Make sure updated structure still apply collection rules (if any)
throw new StructureException($validator->getDescription()); // var_dump($validator->getDescription()); return false;
}
return new Document($this->adapter->updateDocument($data));
}
/**
* @param int $id
*

View file

@ -25,11 +25,11 @@ class Document extends ArrayObject
{
foreach ($input as $key => &$value) {
if (is_array($value)) {
if (isset($value['$uid']) || isset($value['$collection'])) {
if (isset($value['$id']) || isset($value['$collection'])) {
$input[$key] = new self($value);
} else {
foreach ($value as $childKey => $child) {
if (isset($child['$uid']) || isset($child['$collection'])) {
if (isset($child['$id']) || isset($child['$collection'])) {
$value[$childKey] = new self($child);
}
}
@ -43,9 +43,9 @@ class Document extends ArrayObject
/**
* @return string|null
*/
public function getUid()
public function getId()
{
return $this->getAttribute('$uid', null);
return $this->getAttribute('$id', null);
}
/**
@ -190,7 +190,7 @@ class Document extends ArrayObject
*/
public function isEmpty()
{
return empty($this->getUid());
return empty($this->getId());
}
/**

View file

@ -79,7 +79,7 @@ class Authorization extends Validator
$permission = null;
foreach ($permissions[$this->action] as $permission) {
$permission = str_replace(':{self}', ':'.$this->document->getUid(), $permission);
$permission = str_replace(':{self}', ':'.$this->document->getId(), $permission);
if (in_array($permission, self::getRoles())) {
return true;

View file

@ -25,9 +25,9 @@ class Structure extends Validator
*/
protected $rules = [
[
'label' => '$uid',
'label' => '$id',
'$collection' => Database::SYSTEM_COLLECTION_RULES,
'key' => '$uid',
'key' => '$id',
'type' => 'uid',
'default' => null,
'required' => false,
@ -111,7 +111,7 @@ class Structure extends Validator
{
$document = (is_array($document)) ? new Document($document) : $document;
$this->id = $document->getUid();
$this->id = $document->getId();
if (is_null($document->getCollection())) {
$this->message = 'Missing collection attribute $collection';
@ -121,7 +121,7 @@ class Structure extends Validator
$collection = $this->getCollection($document->getCollection());
if (is_null($collection->getUid()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
if (is_null($collection->getId()) || Database::SYSTEM_COLLECTION_COLLECTIONS != $collection->getCollection()) {
$this->message = 'Collection not found';
return false;
@ -247,8 +247,8 @@ class Structure extends Validator
return true;
}
protected function getCollection($uid)
protected function getCollection($id)
{
return $this->database->getDocument($uid);
return $this->database->getDocument($id);
}
}

View file

@ -7,7 +7,7 @@ trait ProjectConsole
public function getProject(): array
{
return [
'$uid' => 'console',
'$id' => 'console',
'name' => 'Appwrite',
'apiKey' => '',
];

View file

@ -31,7 +31,7 @@ trait ProjectCustom
$this->assertEquals(201, $team['headers']['status-code']);
$this->assertEquals('Demo Project Team', $team['body']['name']);
$this->assertNotEmpty($team['body']['$uid']);
$this->assertNotEmpty($team['body']['$id']);
$project = $this->client->call(Client::METHOD_POST, '/projects', [
'origin' => 'http://localhost',
@ -40,7 +40,7 @@ trait ProjectCustom
'x-appwrite-project' => 'console',
], [
'name' => 'Demo Project',
'teamId' => $team['body']['$uid'],
'teamId' => $team['body']['$id'],
'description' => 'Demo Project Description',
'logo' => '',
'url' => 'https://appwrite.io',
@ -55,7 +55,7 @@ trait ProjectCustom
$this->assertEquals(201, $project['headers']['status-code']);
$this->assertNotEmpty($project['body']);
$key = $this->client->call(Client::METHOD_POST, '/projects/' . $project['body']['$uid'] . '/keys', [
$key = $this->client->call(Client::METHOD_POST, '/projects/' . $project['body']['$id'] . '/keys', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_console=' . $this->getRoot()['session'],
@ -86,13 +86,13 @@ trait ProjectCustom
// 'email' => $this->demoEmail,
// 'password' => $this->demoPassword,
// 'session' => $session,
// 'projectUid' => $project['body']['$uid'],
// 'projectUid' => $project['body']['$id'],
// 'projectAPIKeySecret' => $key['body']['secret'],
// 'projectSession' => $this->client->parseCookie($user['headers']['set-cookie'])['a_session_' . $project['body']['$uid']],
// 'projectSession' => $this->client->parseCookie($user['headers']['set-cookie'])['a_session_' . $project['body']['$id']],
// ];
self::$project = [
'$uid' => $project['body']['$uid'],
'$id' => $project['body']['$id'],
'name' => $project['body']['name'],
'apiKey' => $key['body']['secret'],
];

View file

@ -95,7 +95,7 @@ abstract class Scope extends TestCase
$session = $this->client->parseCookie($session['headers']['set-cookie'])['a_session_console'];
self::$root = [
'$uid' => $root['body']['$uid'],
'$id' => $root['body']['$id'],
'name' => $root['body']['name'],
'email' => $root['body']['email'],
'session' => $session,
@ -114,8 +114,8 @@ abstract class Scope extends TestCase
*/
public function getUser(): array
{
if(isset(self::$user[$this->getProject()['$uid']])) {
return self::$user[$this->getProject()['$uid']];
if(isset(self::$user[$this->getProject()['$id']])) {
return self::$user[$this->getProject()['$id']];
}
$email = uniqid().'user@localhost.test';
@ -125,7 +125,7 @@ abstract class Scope extends TestCase
$user = $this->client->call(Client::METHOD_POST, '/account', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'email' => $email,
'password' => $password,
@ -137,21 +137,21 @@ abstract class Scope extends TestCase
$session = $this->client->call(Client::METHOD_POST, '/account/sessions', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'email' => $email,
'password' => $password,
]);
$session = $this->client->parseCookie($session['headers']['set-cookie'])['a_session_'.$this->getProject()['$uid']];
$session = $this->client->parseCookie($session['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
self::$user[$this->getProject()['$uid']] = [
'$uid' => $user['body']['$uid'],
self::$user[$this->getProject()['$id']] = [
'$id' => $user['body']['$id'],
'name' => $user['body']['name'],
'email' => $user['body']['email'],
'session' => $session,
];
return self::$user[$this->getProject()['$uid']];
return self::$user[$this->getProject()['$id']];
}
}

View file

@ -8,7 +8,7 @@ trait SideClient
{
return [
'origin' => 'http://localhost',
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $this->getUser()['session'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $this->getUser()['session'],
];
}
}

View file

@ -18,18 +18,18 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => $password,
'name' => $name,
]);
$uid = $response['body']['$uid'];
$id = $response['body']['$id'];
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsNumeric($response['body']['registration']);
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
@ -40,7 +40,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => $password,
@ -52,7 +52,7 @@ trait AccountBase
sleep(5);
return [
'uid' => $uid,
'uid' => $id,
'email' => $email,
'password' => $password,
'name' => $name,
@ -73,7 +73,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => $password,
@ -81,8 +81,8 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 201);
$sessionId = $response['body']['$uid'];
$session = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$uid']];
$sessionId = $response['body']['$id'];
$session = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
/**
* Test for FAILURE
@ -90,7 +90,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email.'x',
'password' => $password,
@ -101,7 +101,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => $password.'x',
@ -112,7 +112,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => '',
'password' => '',
@ -141,18 +141,18 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]));
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsNumeric($response['body']['registration']);
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $name);
$this->assertContains('*', $response['body']['roles']);
$this->assertContains('user:'.$response['body']['$uid'], $response['body']['roles']);
$this->assertContains('user:'.$response['body']['$id'], $response['body']['roles']);
$this->assertContains('role:1', $response['body']['roles']);
$this->assertCount(3, $response['body']['roles']);
@ -161,15 +161,15 @@ trait AccountBase
*/
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]));
$this->assertEquals($response['headers']['status-code'], 401);
$response = $this->client->call(Client::METHOD_GET, '/account', [
'content-type' => 'application/json',
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session.'xx',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session.'xx',
'x-appwrite-project' => $this->getProject()['$id'],
]);
$this->assertEquals($response['headers']['status-code'], 401);
@ -190,8 +190,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account/prefs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]));
$this->assertEquals($response['headers']['status-code'], 200);
@ -205,7 +205,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account/prefs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]));
$this->assertEquals($response['headers']['status-code'], 401);
@ -227,15 +227,15 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]));
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertCount(1, $response['body']);
$this->assertEquals($sessionId, $response['body'][0]['$uid']);
$this->assertEquals($sessionId, $response['body'][0]['$id']);
$this->assertIsArray($response['body'][0]['OS']);
$this->assertEquals('Windows', $response['body'][0]['OS']['name']);
@ -266,7 +266,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]));
$this->assertEquals($response['headers']['status-code'], 401);
@ -288,8 +288,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]));
$this->assertEquals($response['headers']['status-code'], 200);
@ -353,7 +353,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account/logs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]));
$this->assertEquals($response['headers']['status-code'], 401);
@ -378,8 +378,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/name', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'name' => $newName
]);
@ -388,7 +388,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsNumeric($response['body']['registration']);
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], $newName);
@ -399,7 +399,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/name', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]));
$this->assertEquals($response['headers']['status-code'], 401);
@ -407,8 +407,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/name', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
]);
@ -417,8 +417,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/name', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'name' => 'ocSRq1d3QphHivJyUmYY7WMnrxyjdk5YvVwcDqx2zS0coxESN8RmsQwLWw5Whnf0WbVohuFWTRAaoKgCOO0Y0M7LwgFnZmi8881Y7'
]);
@ -445,8 +445,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'password' => 'new-password',
'old-password' => $password,
@ -456,7 +456,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsNumeric($response['body']['registration']);
$this->assertEquals($response['body']['email'], $email);
$this->assertEquals($response['body']['name'], 'New Name');
@ -464,7 +464,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => 'new-password',
@ -478,7 +478,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]));
$this->assertEquals($response['headers']['status-code'], 401);
@ -486,8 +486,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
]);
@ -512,8 +512,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/email', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'email' => $newEmail,
'password' => 'new-password',
@ -523,7 +523,7 @@ trait AccountBase
$this->assertIsArray($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsNumeric($response['body']['registration']);
$this->assertEquals($response['body']['email'], $newEmail);
$this->assertEquals($response['body']['name'], 'New Name');
@ -534,7 +534,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/email', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]));
$this->assertEquals($response['headers']['status-code'], 401);
@ -542,8 +542,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/email', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
]);
@ -568,8 +568,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'prefs' => [
'key1' => 'value1',
@ -590,7 +590,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]));
$this->assertEquals($response['headers']['status-code'], 401);
@ -598,8 +598,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'prefs' => '{}'
]);
@ -610,8 +610,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'prefs' => '[]'
]);
@ -621,8 +621,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PATCH, '/account/prefs', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'prefs' => '{"test": "value"}'
]);
@ -647,15 +647,15 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/verification', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'url' => 'http://localhost/verification',
]);
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(2, $response['body']['type']);
$this->assertIsNumeric($response['body']['expire']);
@ -673,8 +673,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/recovery', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'url' => 'localhost/recovery',
]);
@ -684,8 +684,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/recovery', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'url' => 'http://remotehost/recovery',
]);
@ -702,7 +702,7 @@ trait AccountBase
*/
public function testUpdateAccountVerification($data):array
{
$uid = (isset($data['uid'])) ? $data['uid'] : '';
$id = (isset($data['uid'])) ? $data['uid'] : '';
$session = (isset($data['session'])) ? $data['session'] : '';
$verification = (isset($data['verification'])) ? $data['verification'] : '';
@ -712,10 +712,10 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PUT, '/account/verification', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'userId' => $uid,
'userId' => $id,
'secret' => $verification,
]);
@ -727,8 +727,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PUT, '/account/verification', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'userId' => 'ewewe',
'secret' => $verification,
@ -739,10 +739,10 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PUT, '/account/verification', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]), [
'userId' => $uid,
'userId' => $id,
'secret' => 'sdasdasdasd',
]);
@ -766,22 +766,22 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => $password,
]);
$sessionNewUid = $response['body']['$uid'];
$sessionNew = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$uid']];
$sessionNewUid = $response['body']['$id'];
$sessionNew = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
$this->assertEquals($response['headers']['status-code'], 201);
$response = $this->client->call(Client::METHOD_GET, '/account', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $sessionNew,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
]);
$this->assertEquals($response['headers']['status-code'], 200);
@ -789,8 +789,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_DELETE, '/account/sessions/'.$sessionNewUid, array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $sessionNew,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
]));
$this->assertEquals($response['headers']['status-code'], 204);
@ -798,8 +798,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]));
$this->assertEquals($response['headers']['status-code'], 200);
@ -810,8 +810,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $sessionNew,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
]);
$this->assertEquals($response['headers']['status-code'], 401);
@ -833,21 +833,21 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => $password,
]);
$sessionNew = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$uid']];
$sessionNew = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
$this->assertEquals($response['headers']['status-code'], 201);
$response = $this->client->call(Client::METHOD_GET, '/account', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $sessionNew,
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
'x-appwrite-project' => $this->getProject()['$id'],
]);
$this->assertEquals($response['headers']['status-code'], 200);
@ -855,8 +855,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_DELETE, '/account/sessions/current', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $sessionNew,
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
'x-appwrite-project' => $this->getProject()['$id'],
]);
$this->assertEquals($response['headers']['status-code'], 204);
@ -867,8 +867,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account', [
'origin' => 'http://localhost',
'content-type' => 'application/json',
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $sessionNew,
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $sessionNew,
'x-appwrite-project' => $this->getProject()['$id'],
]);
$this->assertEquals($response['headers']['status-code'], 401);
@ -889,8 +889,8 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_DELETE, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'cookie' => 'a_session_'.$this->getProject()['$uid'].'=' . $session,
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $session,
]));
$this->assertEquals($response['headers']['status-code'], 204);
@ -901,7 +901,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]));
$this->assertEquals($response['headers']['status-code'], 401);
@ -915,13 +915,13 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/sessions', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'password' => $password,
]);
$data['session'] = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$uid']];
$data['session'] = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
return $data;
}
@ -940,14 +940,14 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/recovery', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'url' => 'http://localhost/recovery',
]);
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(3, $response['body']['type']);
$this->assertIsNumeric($response['body']['expire']);
@ -965,7 +965,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/recovery', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'url' => 'localhost/recovery',
@ -976,7 +976,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/recovery', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $email,
'url' => 'http://remotehost/recovery',
@ -987,7 +987,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_POST, '/account/recovery', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => 'not-found@localhost.test',
'url' => 'http://localhost/recovery',
@ -1005,7 +1005,7 @@ trait AccountBase
*/
public function testUpdateAccountRecovery($data):array
{
$uid = (isset($data['uid'])) ? $data['uid'] : '';
$id = (isset($data['uid'])) ? $data['uid'] : '';
$recovery = (isset($data['recovery'])) ? $data['recovery'] : '';
$newPassowrd = 'test-recovery';
@ -1015,9 +1015,9 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PUT, '/account/recovery', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => $uid,
'userId' => $id,
'secret' => $recovery,
'password-a' => $newPassowrd,
'password-b' => $newPassowrd,
@ -1031,7 +1031,7 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PUT, '/account/recovery', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => 'ewewe',
'secret' => $recovery,
@ -1044,9 +1044,9 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PUT, '/account/recovery', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => $uid,
'userId' => $id,
'secret' => 'sdasdasdasd',
'password-a' => $newPassowrd,
'password-b' => $newPassowrd,
@ -1057,9 +1057,9 @@ trait AccountBase
$response = $this->client->call(Client::METHOD_PUT, '/account/recovery', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'userId' => $uid,
'userId' => $id,
'secret' => $recovery,
'password-a' => $newPassowrd.'x',
'password-b' => $newPassowrd,

View file

@ -22,7 +22,7 @@ class AccountCustomClientTest extends Scope
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$this->getProject()['$uid'].'/oauth2', array_merge([
$response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$this->getProject()['$id'].'/oauth2', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => 'console',
@ -38,7 +38,7 @@ class AccountCustomClientTest extends Scope
$response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/'.$provider, array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'success' => 'http://localhost/v1/mock/tests/general/oauth2/success',
'failure' => 'http://localhost/v1/mock/tests/general/oauth2/failure',

View file

@ -23,7 +23,7 @@ class AccountCustomServerTest extends Scope
*/
$response = $this->client->call(Client::METHOD_POST, '/account', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'email' => $email,

View file

@ -12,7 +12,7 @@ trait AvatarsBase
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]);
$this->assertEquals(200, $response['headers']['status-code']);
@ -20,7 +20,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 200,
'height' => 200,
@ -31,7 +31,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 300,
'height' => 300,
@ -47,7 +47,7 @@ trait AvatarsBase
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/unknown', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 300,
'height' => 300,
@ -57,7 +57,7 @@ trait AvatarsBase
$this->assertEquals(400, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/credit-cards/visa', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 2001,
'height' => 300,
@ -75,7 +75,7 @@ trait AvatarsBase
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]);
$this->assertEquals(200, $response['headers']['status-code']);
@ -83,7 +83,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 200,
'height' => 200,
@ -94,7 +94,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 300,
'height' => 300,
@ -110,7 +110,7 @@ trait AvatarsBase
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/unknown', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 300,
'height' => 300,
@ -120,7 +120,7 @@ trait AvatarsBase
$this->assertEquals(400, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/browsers/ch', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 2001,
'height' => 300,
@ -138,7 +138,7 @@ trait AvatarsBase
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]);
$this->assertEquals(200, $response['headers']['status-code']);
@ -146,7 +146,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 200,
'height' => 200,
@ -157,7 +157,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 300,
'height' => 300,
@ -172,7 +172,7 @@ trait AvatarsBase
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/unknown', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 300,
'height' => 300,
@ -182,7 +182,7 @@ trait AvatarsBase
$this->assertEquals(400, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/flags/us', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'width' => 2001,
'height' => 300,
@ -200,7 +200,7 @@ trait AvatarsBase
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'url' => 'https://appwrite.io/images/apple.png',
]);
@ -210,7 +210,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'url' => 'https://appwrite.io/images/apple.png',
'width' => 200,
@ -222,7 +222,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'url' => 'https://appwrite.io/images/apple.png',
'width' => 300,
@ -238,7 +238,7 @@ trait AvatarsBase
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'url' => 'https://appwrite.io/images/unknown.png',
'width' => 300,
@ -249,7 +249,7 @@ trait AvatarsBase
$this->assertEquals(404, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/image', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'url' => 'https://appwrite.io/images/apple.png',
'width' => 2001,
@ -270,7 +270,7 @@ trait AvatarsBase
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'url' => 'https://appwrite.io/',
]);
@ -280,7 +280,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
// $response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
// 'x-appwrite-project' => $this->getProject()['$uid'],
// 'x-appwrite-project' => $this->getProject()['$id'],
// ], [
// 'url' => 'https://www.bbc.com/',
// ]);
@ -290,7 +290,7 @@ trait AvatarsBase
// $this->assertNotEmpty($response['body']);
// $response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
// 'x-appwrite-project' => $this->getProject()['$uid'],
// 'x-appwrite-project' => $this->getProject()['$id'],
// ], [
// 'url' => 'https://edition.cnn.com/',
// ]);
@ -303,7 +303,7 @@ trait AvatarsBase
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'url' => 'unknown-address',
]);
@ -311,7 +311,7 @@ trait AvatarsBase
$this->assertEquals(400, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/favicon', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'url' => 'http://unknown-address.test',
]);
@ -327,7 +327,7 @@ trait AvatarsBase
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'text' => 'url:https://appwrite.io/',
]);
@ -337,7 +337,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'text' => 'url:https://appwrite.io/',
'size' => 200,
@ -348,7 +348,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'text' => 'url:https://appwrite.io/',
'size' => 200,
@ -360,7 +360,7 @@ trait AvatarsBase
$this->assertNotEmpty($response['body']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'text' => 'url:https://appwrite.io/',
'size' => 200,
@ -377,7 +377,7 @@ trait AvatarsBase
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'text' => 'url:https://appwrite.io/',
'size' => 1001,
@ -388,7 +388,7 @@ trait AvatarsBase
$this->assertEquals(400, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'text' => 'url:https://appwrite.io/',
'size' => 400,
@ -399,7 +399,7 @@ trait AvatarsBase
$this->assertEquals(400, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_GET, '/avatars/qr', [
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], [
'text' => 'url:https://appwrite.io/',
'size' => 400,

View file

@ -13,7 +13,7 @@ trait DatabaseBase
*/
$actors = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'name' => 'Actors',
@ -50,7 +50,7 @@ trait DatabaseBase
$movies = $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'name' => 'Movies',
@ -80,7 +80,7 @@ trait DatabaseBase
'default' => [],
'required' => false,
'array' => true,
'list' => [$actors['body']['$uid']],
'list' => [$actors['body']['$id']],
],
],
]);
@ -94,7 +94,7 @@ trait DatabaseBase
$this->assertCount(1, $movies['body']['$permissions']['read']);
$this->assertCount(2, $movies['body']['$permissions']['write']);
return array_merge(['moviesId' => $movies['body']['$uid'], 'actorsId' => $actors['body']['$uid']]);
return array_merge(['moviesId' => $movies['body']['$id'], 'actorsId' => $actors['body']['$id']]);
}
/**
@ -104,7 +104,7 @@ trait DatabaseBase
{
$document1 = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'data' => [
'name' => 'Captain America',
@ -124,13 +124,13 @@ trait DatabaseBase
],
]
],
'read' => ['user:'.$this->getUser()['$uid']],
'write' => ['user:'.$this->getUser()['$uid']],
'read' => ['user:'.$this->getUser()['$id']],
'write' => ['user:'.$this->getUser()['$id']],
]);
$document2 = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'data' => [
'name' => 'Spider-Man: Far From Home',
@ -156,13 +156,13 @@ trait DatabaseBase
],
]
],
'read' => ['user:'.$this->getUser()['$uid']],
'write' => ['user:'.$this->getUser()['$uid']],
'read' => ['user:'.$this->getUser()['$id']],
'write' => ['user:'.$this->getUser()['$id']],
]);
$document3 = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'data' => [
'name' => 'Spider-Man: Homecoming',
@ -182,19 +182,19 @@ trait DatabaseBase
],
],
],
'read' => ['user:'.$this->getUser()['$uid']],
'write' => ['user:'.$this->getUser()['$uid']],
'read' => ['user:'.$this->getUser()['$id']],
'write' => ['user:'.$this->getUser()['$id']],
]);
$document4 = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'data' => [
'releaseYear' => 2020, // Missing title, expect an 400 error
],
'read' => ['user:'.$this->getUser()['$uid']],
'write' => ['user:'.$this->getUser()['$uid']],
'read' => ['user:'.$this->getUser()['$id']],
'write' => ['user:'.$this->getUser()['$id']],
]);
$this->assertEquals($document1['headers']['status-code'], 201);
@ -252,7 +252,7 @@ trait DatabaseBase
{
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'order-field' => 'releaseYear',
'order-type' => 'ASC',
@ -266,7 +266,7 @@ trait DatabaseBase
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'order-field' => 'releaseYear',
'order-type' => 'DESC',
@ -288,7 +288,7 @@ trait DatabaseBase
{
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'limit' => 1,
'order-field' => 'releaseYear',
@ -301,7 +301,7 @@ trait DatabaseBase
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'limit' => 2,
'offset' => 1,
@ -324,7 +324,7 @@ trait DatabaseBase
{
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'limit' => 1,
'order-field' => 'releaseYear',
@ -337,7 +337,7 @@ trait DatabaseBase
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'limit' => 2,
'offset' => 1,
@ -359,7 +359,7 @@ trait DatabaseBase
{
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => 'Captain America',
]);
@ -369,7 +369,7 @@ trait DatabaseBase
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => 'Homecoming',
]);
@ -379,7 +379,7 @@ trait DatabaseBase
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => 'spider',
]);
@ -398,7 +398,7 @@ trait DatabaseBase
{
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'filters' => [
'actors.firstName=Tom'
@ -411,7 +411,7 @@ trait DatabaseBase
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'filters' => [
'releaseYear=1944'
@ -423,7 +423,7 @@ trait DatabaseBase
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'filters' => [
'releaseYear!=1944'
@ -444,17 +444,17 @@ trait DatabaseBase
{
$document = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'data' => [
'name' => 'Thor: Ragnaroc',
'releaseYear' => 2017,
],
'read' => ['user:'.$this->getUser()['$uid']],
'write' => ['user:'.$this->getUser()['$uid']],
'read' => ['user:'.$this->getUser()['$id']],
'write' => ['user:'.$this->getUser()['$id']],
]);
$id = $document['body']['$uid'];
$id = $document['body']['$id'];
$collection = $document['body']['$collection'];
$this->assertEquals($document['headers']['status-code'], 201);
@ -463,7 +463,7 @@ trait DatabaseBase
$document = $this->client->call(Client::METHOD_PATCH, '/database/collections/' . $collection . '/documents/' . $id, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'data' => [
'name' => 'Thor: Ragnarok'
@ -476,10 +476,10 @@ trait DatabaseBase
$document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $collection . '/documents/' . $id, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$id = $document['body']['$uid'];
$id = $document['body']['$id'];
$collection = $document['body']['$collection'];
$this->assertEquals($document['headers']['status-code'], 200);
@ -496,38 +496,38 @@ trait DatabaseBase
{
$document = $this->client->call(Client::METHOD_POST, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'data' => [
'name' => 'Thor: Ragnarok',
'releaseYear' => 2017,
],
'read' => ['user:'.$this->getUser()['$uid']],
'write' => ['user:'.$this->getUser()['$uid']],
'read' => ['user:'.$this->getUser()['$id']],
'write' => ['user:'.$this->getUser()['$id']],
]);
$id = $document['body']['$uid'];
$id = $document['body']['$id'];
$collection = $document['body']['$collection'];
$this->assertEquals($document['headers']['status-code'], 201);
$document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $collection . '/documents/' . $id, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($document['headers']['status-code'], 200);
$document = $this->client->call(Client::METHOD_DELETE, '/database/collections/' . $collection . '/documents/' . $id, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($document['headers']['status-code'], 204);
$document = $this->client->call(Client::METHOD_GET, '/database/collections/' . $collection . '/documents/' . $id, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($document['headers']['status-code'], 404);

View file

@ -13,7 +13,7 @@ trait HealthBase
*/
$response = $this->client->call(Client::METHOD_GET, '/health', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
@ -33,7 +33,7 @@ trait HealthBase
*/
$response = $this->client->call(Client::METHOD_GET, '/health/db', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
@ -53,7 +53,7 @@ trait HealthBase
*/
$response = $this->client->call(Client::METHOD_GET, '/health/db', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
@ -73,7 +73,7 @@ trait HealthBase
*/
$response = $this->client->call(Client::METHOD_GET, '/health/time', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
@ -97,7 +97,7 @@ trait HealthBase
*/
$response = $this->client->call(Client::METHOD_GET, '/health/webhooks', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
@ -118,7 +118,7 @@ trait HealthBase
*/
$response = $this->client->call(Client::METHOD_GET, '/health/storage/local', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
@ -138,7 +138,7 @@ trait HealthBase
*/
$response = $this->client->call(Client::METHOD_GET, '/health/storage/anti-virus', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);

View file

@ -13,7 +13,7 @@ trait LocaleBase
*/
$response = $this->client->call(Client::METHOD_GET, '/locale', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($response['headers']['status-code'], 200);
@ -39,7 +39,7 @@ trait LocaleBase
*/
$response = $this->client->call(Client::METHOD_GET, '/locale/countries', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($response['headers']['status-code'], 200);
@ -51,7 +51,7 @@ trait LocaleBase
$response = $this->client->call(Client::METHOD_GET, '/locale/countries', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-locale' => 'es',
]);
@ -74,7 +74,7 @@ trait LocaleBase
*/
$response = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($response['headers']['status-code'], 200);
@ -86,7 +86,7 @@ trait LocaleBase
$response = $this->client->call(Client::METHOD_GET, '/locale/countries/eu', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-locale' => 'es',
]);
@ -109,7 +109,7 @@ trait LocaleBase
*/
$response = $this->client->call(Client::METHOD_GET, '/locale/countries/phones', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($response['headers']['status-code'], 200);
@ -132,7 +132,7 @@ trait LocaleBase
*/
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($response['headers']['status-code'], 200);
@ -143,7 +143,7 @@ trait LocaleBase
// Test locale code change to ES
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-locale' => 'es',
]);
@ -167,7 +167,7 @@ trait LocaleBase
*/
$response = $this->client->call(Client::METHOD_GET, '/locale/currencies', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($response['headers']['status-code'], 200);
@ -195,7 +195,7 @@ trait LocaleBase
foreach ($languages as $lang) {
$response = $this->client->call(Client::METHOD_GET, '/locale/countries', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-locale' => $lang,
]);
@ -212,7 +212,7 @@ trait LocaleBase
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-locale' => $lang,
]);

View file

@ -14,7 +14,7 @@ trait StorageBase
*/
$file = $this->client->call(Client::METHOD_POST, '/storage/files', array_merge([
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
'read' => ['*'],
@ -23,7 +23,7 @@ trait StorageBase
]);
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertNotEmpty($file['body']['$uid']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertEquals('files', $file['body']['$collection']);
$this->assertIsInt($file['body']['dateCreated']);
$this->assertEquals('logo.png', $file['body']['name']);
@ -39,7 +39,7 @@ trait StorageBase
/**
* Test for FAILURE
*/
return ['fileId' => $file['body']['$uid']];
return ['fileId' => $file['body']['$id']];
}
/**
@ -52,11 +52,11 @@ trait StorageBase
*/
$file1 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($file1['headers']['status-code'], 200);
$this->assertNotEmpty($file1['body']['$uid']);
$this->assertNotEmpty($file1['body']['$id']);
$this->assertIsInt($file1['body']['dateCreated']);
$this->assertEquals('logo.png', $file1['body']['name']);
$this->assertEquals('image/png', $file1['body']['mimeType']);
@ -74,7 +74,7 @@ trait StorageBase
$file2 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/preview', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $file2['headers']['status-code']);
@ -83,7 +83,7 @@ trait StorageBase
$file3 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/download', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $file3['headers']['status-code']);
@ -93,7 +93,7 @@ trait StorageBase
$file4 = $this->client->call(Client::METHOD_GET, '/storage/files/' . $data['fileId'] . '/view', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $file4['headers']['status-code']);
@ -117,7 +117,7 @@ trait StorageBase
*/
$files = $this->client->call(Client::METHOD_GET, '/storage/files', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $files['headers']['status-code']);
@ -141,14 +141,14 @@ trait StorageBase
*/
$file = $this->client->call(Client::METHOD_PUT, '/storage/files/' . $data['fileId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'read' => ['*'],
'write' => ['*'],
]);
$this->assertEquals(200, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$uid']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertIsInt($file['body']['dateCreated']);
$this->assertEquals('logo.png', $file['body']['name']);
$this->assertEquals('image/png', $file['body']['mimeType']);
@ -181,7 +181,7 @@ trait StorageBase
*/
$file = $this->client->call(Client::METHOD_DELETE, '/storage/files/' . $data['fileId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(204, $file['headers']['status-code']);

View file

@ -13,30 +13,30 @@ trait TeamsBase
*/
$response1 = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'Arsenal'
]);
$this->assertEquals(201, $response1['headers']['status-code']);
$this->assertNotEmpty($response1['body']['$uid']);
$this->assertNotEmpty($response1['body']['$id']);
$this->assertEquals('Arsenal', $response1['body']['name']);
$this->assertGreaterThan(-1, $response1['body']['sum']);
$this->assertIsInt($response1['body']['sum']);
$this->assertIsInt($response1['body']['dateCreated']);
$teamUid = $response1['body']['$uid'];
$teamUid = $response1['body']['$id'];
$teamName = $response1['body']['name'];
$response2 = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'Manchester United'
]);
$this->assertEquals(201, $response2['headers']['status-code']);
$this->assertNotEmpty($response2['body']['$uid']);
$this->assertNotEmpty($response2['body']['$id']);
$this->assertEquals('Manchester United', $response2['body']['name']);
$this->assertGreaterThan(-1, $response2['body']['sum']);
$this->assertIsInt($response2['body']['sum']);
@ -44,13 +44,13 @@ trait TeamsBase
$response3 = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'Newcastle'
]);
$this->assertEquals(201, $response3['headers']['status-code']);
$this->assertNotEmpty($response3['body']['$uid']);
$this->assertNotEmpty($response3['body']['$id']);
$this->assertEquals('Newcastle', $response3['body']['name']);
$this->assertGreaterThan(-1, $response3['body']['sum']);
$this->assertIsInt($response3['body']['sum']);
@ -61,7 +61,7 @@ trait TeamsBase
*/
$response = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
]);
@ -75,18 +75,18 @@ trait TeamsBase
*/
public function testGetTeam($data):array
{
$uid = (isset($data['teamUid'])) ? $data['teamUid'] : '';
$id = (isset($data['teamUid'])) ? $data['teamUid'] : '';
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/teams/'.$uid, array_merge([
$response = $this->client->call(Client::METHOD_GET, '/teams/'.$id, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals('Arsenal', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
@ -109,7 +109,7 @@ trait TeamsBase
*/
$response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
@ -119,7 +119,7 @@ trait TeamsBase
$response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'limit' => 2,
]);
@ -131,7 +131,7 @@ trait TeamsBase
$response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'offset' => 1,
]);
@ -143,7 +143,7 @@ trait TeamsBase
$response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => 'Manchester',
]);
@ -156,7 +156,7 @@ trait TeamsBase
$response = $this->client->call(Client::METHOD_GET, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => 'United',
]);
@ -181,27 +181,27 @@ trait TeamsBase
*/
$response = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'Demo'
]);
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
$this->assertIsInt($response['body']['dateCreated']);
$response = $this->client->call(Client::METHOD_PUT, '/teams/'.$response['body']['$uid'], array_merge([
$response = $this->client->call(Client::METHOD_PUT, '/teams/'.$response['body']['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'Demo New'
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals('Demo New', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
@ -210,9 +210,9 @@ trait TeamsBase
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_PUT, '/teams/'.$response['body']['$uid'], array_merge([
$response = $this->client->call(Client::METHOD_PUT, '/teams/'.$response['body']['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
]);
@ -228,15 +228,15 @@ trait TeamsBase
*/
$response = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'Demo'
]);
$teamUid = $response['body']['$uid'];
$teamUid = $response['body']['$id'];
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals('Demo', $response['body']['name']);
$this->assertGreaterThan(-1, $response['body']['sum']);
$this->assertIsInt($response['body']['sum']);
@ -244,7 +244,7 @@ trait TeamsBase
$response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(204, $response['headers']['status-code']);
@ -255,7 +255,7 @@ trait TeamsBase
*/
$response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(404, $response['headers']['status-code']);

View file

@ -18,11 +18,11 @@ trait TeamsBaseClient
*/
$response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid.'/memberships', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body'][0]['$uid']);
$this->assertNotEmpty($response['body'][0]['$id']);
$this->assertEquals($this->getUser()['name'], $response['body'][0]['name']);
$this->assertEquals($this->getUser()['email'], $response['body'][0]['email']);
$this->assertEquals('owner', $response['body'][0]['roles'][0]);
@ -48,7 +48,7 @@ trait TeamsBaseClient
*/
$response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'email' => $email,
'name' => 'Friend User',
@ -57,7 +57,7 @@ trait TeamsBaseClient
]);
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertNotEmpty($response['body']['userId']);
$this->assertNotEmpty($response['body']['teamId']);
$this->assertCount(2, $response['body']['roles']);
@ -79,7 +79,7 @@ trait TeamsBaseClient
*/
$response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'email' => 'dasdkaskdjaskdjasjkd',
'name' => 'Friend User',
@ -91,7 +91,7 @@ trait TeamsBaseClient
$response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'email' => $email,
'name' => 'Friend User',
@ -103,7 +103,7 @@ trait TeamsBaseClient
$response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'email' => $email,
'name' => 'Friend User',
@ -137,14 +137,14 @@ trait TeamsBaseClient
$response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$inviteUid.'/status', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => $secret,
'userId' => $userUid,
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$uid']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertNotEmpty($response['body']['userId']);
$this->assertNotEmpty($response['body']['teamId']);
$this->assertCount(2, $response['body']['roles']);
@ -157,7 +157,7 @@ trait TeamsBaseClient
$response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$inviteUid.'/status', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => 'sdasdasd',
'userId' => $userUid,
@ -168,7 +168,7 @@ trait TeamsBaseClient
$response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$inviteUid.'/status', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => '',
'userId' => $userUid,
@ -179,7 +179,7 @@ trait TeamsBaseClient
$response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$inviteUid.'/status', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => $secret,
'userId' => 'sdasd',
@ -190,7 +190,7 @@ trait TeamsBaseClient
$response = $this->client->call(Client::METHOD_PATCH, '/teams/'.$teamUid.'/memberships/'.$inviteUid.'/status', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'secret' => $secret,
'userId' => '',
@ -215,7 +215,7 @@ trait TeamsBaseClient
$response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamUid.'/memberships/'.$inviteUid, array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(204, $response['headers']['status-code']);
@ -227,7 +227,7 @@ trait TeamsBaseClient
$response = $this->client->call(Client::METHOD_GET, '/teams/'.$teamUid.'/memberships/'.$inviteUid, array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);

View file

@ -11,14 +11,14 @@ trait TeamsBaseServer
*/
public function testGetTeamMemberships($data):array
{
$uid = (isset($data['teamUid'])) ? $data['teamUid'] : '';
$id = (isset($data['teamUid'])) ? $data['teamUid'] : '';
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/teams/'.$uid.'/memberships', array_merge([
$response = $this->client->call(Client::METHOD_GET, '/teams/'.$id.'/memberships', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);

View file

@ -13,7 +13,7 @@ trait UsersBase
*/
$user = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'email' => 'users.service@example.com',
'password' => 'password',
@ -27,7 +27,7 @@ trait UsersBase
$this->assertGreaterThan(0, $user['body']['registration']);
$this->assertIsArray($user['body']['roles']);
return ['userId' => $user['body']['$uid']];
return ['userId' => $user['body']['$id']];
}
/**
@ -40,7 +40,7 @@ trait UsersBase
*/
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
@ -52,7 +52,7 @@ trait UsersBase
$sessions = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/sessions', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($sessions['headers']['status-code'], 200);
@ -60,7 +60,7 @@ trait UsersBase
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($logs['headers']['status-code'], 200);
@ -68,7 +68,7 @@ trait UsersBase
$users = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($users['headers']['status-code'], 200);
@ -79,7 +79,7 @@ trait UsersBase
$users = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => 'example.com'
]);
@ -105,7 +105,7 @@ trait UsersBase
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/status', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'status' => 2,
]);
@ -115,7 +115,7 @@ trait UsersBase
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
@ -134,7 +134,7 @@ trait UsersBase
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'prefs' => [
'key1' => 'value1',
@ -151,7 +151,7 @@ trait UsersBase
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'prefs' => 'bad-string',
]);
@ -160,7 +160,7 @@ trait UsersBase
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$uid'],
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 400);

View file

@ -68,13 +68,13 @@ class AuthTest extends TestCase
$hash = Auth::hash($secret);
$tokens1 = [
new Document([
'$uid' => 'token1',
'$id' => 'token1',
'type' => Auth::TOKEN_TYPE_LOGIN,
'expire' => time() + 60 * 60 * 24,
'secret' => $hash,
]),
new Document([
'$uid' => 'token2',
'$id' => 'token2',
'type' => Auth::TOKEN_TYPE_LOGIN,
'expire' => time() - 60 * 60 * 24,
'secret' => 'secret2',
@ -83,13 +83,13 @@ class AuthTest extends TestCase
$tokens2 = [
new Document([ // Correct secret and type time, wrong expire time
'$uid' => 'token1',
'$id' => 'token1',
'type' => Auth::TOKEN_TYPE_LOGIN,
'expire' => time() - 60 * 60 * 24,
'secret' => $hash,
]),
new Document([
'$uid' => 'token2',
'$id' => 'token2',
'type' => Auth::TOKEN_TYPE_LOGIN,
'expire' => time() - 60 * 60 * 24,
'secret' => 'secret2',
@ -98,13 +98,13 @@ class AuthTest extends TestCase
$tokens3 = [ // Correct secret and expire time, wrong type
new Document([
'$uid' => 'token1',
'$id' => 'token1',
'type' => Auth::TOKEN_TYPE_RECOVERY,
'expire' => time() + 60 * 60 * 24,
'secret' => $hash,
]),
new Document([
'$uid' => 'token2',
'$id' => 'token2',
'type' => Auth::TOKEN_TYPE_LOGIN,
'expire' => time() - 60 * 60 * 24,
'secret' => 'secret2',