New DB rules
This commit is contained in:
parent
e3c23c0c70
commit
555b761b44
7 changed files with 112 additions and 15 deletions
2
public/dist/styles/default-ltr.css
vendored
2
public/dist/styles/default-ltr.css
vendored
File diff suppressed because one or more lines are too long
2
public/dist/styles/default-rtl.css
vendored
2
public/dist/styles/default-rtl.css
vendored
File diff suppressed because one or more lines are too long
|
@ -1121,7 +1121,6 @@ ol {
|
||||||
.func-start(-10px);
|
.func-start(-10px);
|
||||||
max-width: 280px;
|
max-width: 280px;
|
||||||
min-width: 240px;
|
min-width: 240px;
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
border: solid;
|
border: solid;
|
||||||
|
@ -1134,6 +1133,11 @@ ol {
|
||||||
.func-start(30px);
|
.func-start(30px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.arrow-end:before {
|
||||||
|
.func-end(30px);
|
||||||
|
.func-start(unset);
|
||||||
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
border-bottom: solid 1px var(--config-color-fade-super);
|
border-bottom: solid 1px var(--config-color-fade-super);
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -1147,13 +1151,13 @@ ol {
|
||||||
height: auto;
|
height: auto;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 10px 25px;
|
padding: 10px 15px;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
border: none;
|
border: none;
|
||||||
max-width: 260px;
|
max-width: 260px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
width: 100%;
|
width: ~"calc(100% - 30px)";
|
||||||
text-align: @config-start;
|
text-align: @config-start;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|
|
@ -124,11 +124,24 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.switch-theme {
|
||||||
|
margin: 2px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
width: 40px;
|
width: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.account-button {
|
||||||
|
background: transparent;
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 0;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.notifications {
|
.notifications {
|
||||||
position: relative;
|
position: relative;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
|
74
src/Appwrite/Database/Validator/DocumentId.php
Normal file
74
src/Appwrite/Database/Validator/DocumentId.php
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Database\Validator;
|
||||||
|
|
||||||
|
use Appwrite\Database\Database;
|
||||||
|
use Appwrite\Database\Document;
|
||||||
|
use Utopia\Validator;
|
||||||
|
|
||||||
|
class DocumentId extends Validator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $message = 'Document not found.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Database
|
||||||
|
*/
|
||||||
|
protected $database = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure constructor.
|
||||||
|
*
|
||||||
|
* @param Database $database
|
||||||
|
*/
|
||||||
|
public function __construct(Database $database)
|
||||||
|
{
|
||||||
|
$this->database = $database;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Description.
|
||||||
|
*
|
||||||
|
* Returns validator description
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDescription()
|
||||||
|
{
|
||||||
|
return $this->message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is valid.
|
||||||
|
*
|
||||||
|
* Returns true if valid or false if not.
|
||||||
|
*
|
||||||
|
* @param $value
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isValid($id)
|
||||||
|
{
|
||||||
|
$document = $this->database->getDocument($id);
|
||||||
|
|
||||||
|
if(!$document) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$document instanceof Document) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$document->getId()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($document->getCollection() !== Database::SYSTEM_COLLECTION_FILES) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,7 +28,7 @@ class Structure extends Validator
|
||||||
'label' => '$id',
|
'label' => '$id',
|
||||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||||
'key' => '$id',
|
'key' => '$id',
|
||||||
'type' => 'uid',
|
'type' => 'id',
|
||||||
'default' => null,
|
'default' => null,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'array' => false,
|
'array' => false,
|
||||||
|
@ -37,7 +37,7 @@ class Structure extends Validator
|
||||||
'label' => '$collection',
|
'label' => '$collection',
|
||||||
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
'$collection' => Database::SYSTEM_COLLECTION_RULES,
|
||||||
'key' => '$collection',
|
'key' => '$collection',
|
||||||
'type' => 'uid',
|
'type' => 'id',
|
||||||
'default' => null,
|
'default' => null,
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'array' => false,
|
'array' => false,
|
||||||
|
@ -147,7 +147,7 @@ class Structure extends Validator
|
||||||
$validator = null;
|
$validator = null;
|
||||||
|
|
||||||
switch ($ruleType) {
|
switch ($ruleType) {
|
||||||
case 'uid':
|
case 'id':
|
||||||
$validator = new UID();
|
$validator = new UID();
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
|
@ -179,8 +179,14 @@ class Structure extends Validator
|
||||||
break;
|
break;
|
||||||
case 'document':
|
case 'document':
|
||||||
$validator = new Collection($this->database, (isset($rule['list'])) ? $rule['list'] : []);
|
$validator = new Collection($this->database, (isset($rule['list'])) ? $rule['list'] : []);
|
||||||
// $validator = new Collection($this->database, (isset($rule['list'])) ? $rule['list'] : [],
|
$value = $document->getAttribute($key);
|
||||||
// ['$permissions' => (isset($document['$permissions'])) ? $document['$permissions'] : []]);
|
break;
|
||||||
|
case 'documentId':
|
||||||
|
$validator = new DocumentId($this->database, (isset($rule['list'])) ? $rule['list'] : []);
|
||||||
|
$value = $document->getAttribute($key);
|
||||||
|
break;
|
||||||
|
case 'fileId':
|
||||||
|
$validator = new DocumentId($this->database, [Database::SYSTEM_COLLECTION_FILES]);
|
||||||
$value = $document->getAttribute($key);
|
$value = $document->getAttribute($key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ trait AccountBase
|
||||||
sleep(5);
|
sleep(5);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'uid' => $id,
|
'id' => $id,
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
|
@ -702,7 +702,7 @@ trait AccountBase
|
||||||
*/
|
*/
|
||||||
public function testUpdateAccountVerification($data):array
|
public function testUpdateAccountVerification($data):array
|
||||||
{
|
{
|
||||||
$id = (isset($data['uid'])) ? $data['uid'] : '';
|
$id = (isset($data['id'])) ? $data['id'] : '';
|
||||||
$session = (isset($data['session'])) ? $data['session'] : '';
|
$session = (isset($data['session'])) ? $data['session'] : '';
|
||||||
$verification = (isset($data['verification'])) ? $data['verification'] : '';
|
$verification = (isset($data['verification'])) ? $data['verification'] : '';
|
||||||
|
|
||||||
|
@ -772,7 +772,7 @@ trait AccountBase
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$sessionNewUid = $response['body']['$id'];
|
$sessionNewId = $response['body']['$id'];
|
||||||
$sessionNew = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
|
$sessionNew = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
|
||||||
|
|
||||||
$this->assertEquals($response['headers']['status-code'], 201);
|
$this->assertEquals($response['headers']['status-code'], 201);
|
||||||
|
@ -786,7 +786,7 @@ trait AccountBase
|
||||||
|
|
||||||
$this->assertEquals($response['headers']['status-code'], 200);
|
$this->assertEquals($response['headers']['status-code'], 200);
|
||||||
|
|
||||||
$response = $this->client->call(Client::METHOD_DELETE, '/account/sessions/'.$sessionNewUid, array_merge([
|
$response = $this->client->call(Client::METHOD_DELETE, '/account/sessions/'.$sessionNewId, array_merge([
|
||||||
'origin' => 'http://localhost',
|
'origin' => 'http://localhost',
|
||||||
'content-type' => 'application/json',
|
'content-type' => 'application/json',
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
@ -1005,7 +1005,7 @@ trait AccountBase
|
||||||
*/
|
*/
|
||||||
public function testUpdateAccountRecovery($data):array
|
public function testUpdateAccountRecovery($data):array
|
||||||
{
|
{
|
||||||
$id = (isset($data['uid'])) ? $data['uid'] : '';
|
$id = (isset($data['id'])) ? $data['id'] : '';
|
||||||
$recovery = (isset($data['recovery'])) ? $data['recovery'] : '';
|
$recovery = (isset($data['recovery'])) ? $data['recovery'] : '';
|
||||||
$newPassowrd = 'test-recovery';
|
$newPassowrd = 'test-recovery';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue