1
0
Fork 0
mirror of synced 2024-06-18 18:54:55 +12:00

New DB rules

This commit is contained in:
Eldad Fux 2020-04-22 10:03:34 +03:00
parent e3c23c0c70
commit 555b761b44
7 changed files with 112 additions and 15 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1121,7 +1121,6 @@ ol {
.func-start(-10px);
max-width: 280px;
min-width: 240px;
overflow: hidden;
&:before {
border: solid;
@ -1134,6 +1133,11 @@ ol {
.func-start(30px);
}
&.arrow-end:before {
.func-end(30px);
.func-start(unset);
}
li {
border-bottom: solid 1px var(--config-color-fade-super);
margin: 0;
@ -1147,13 +1151,13 @@ ol {
height: auto;
line-height: 30px;
display: inline-block;
padding: 10px 25px;
padding: 10px 15px;
color: inherit;
font-size: 14px;
border: none;
max-width: 260px;
cursor: pointer;
width: 100%;
width: ~"calc(100% - 30px)";
text-align: @config-start;
&:hover {

View file

@ -124,11 +124,24 @@
}
}
.switch-theme {
margin: 2px 0;
}
.avatar {
height: 40px;
width: 40px;
}
.account-button {
background: transparent;
position: absolute;
width: 100%;
height: 40px;
border-radius: 0;
z-index: 1;
}
.notifications {
position: relative;
font-size: 20px;

View 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;
}
}

View file

@ -28,7 +28,7 @@ class Structure extends Validator
'label' => '$id',
'$collection' => Database::SYSTEM_COLLECTION_RULES,
'key' => '$id',
'type' => 'uid',
'type' => 'id',
'default' => null,
'required' => false,
'array' => false,
@ -37,7 +37,7 @@ class Structure extends Validator
'label' => '$collection',
'$collection' => Database::SYSTEM_COLLECTION_RULES,
'key' => '$collection',
'type' => 'uid',
'type' => 'id',
'default' => null,
'required' => true,
'array' => false,
@ -147,7 +147,7 @@ class Structure extends Validator
$validator = null;
switch ($ruleType) {
case 'uid':
case 'id':
$validator = new UID();
break;
case 'text':
@ -179,8 +179,14 @@ class Structure extends Validator
break;
case 'document':
$validator = new Collection($this->database, (isset($rule['list'])) ? $rule['list'] : []);
// $validator = new Collection($this->database, (isset($rule['list'])) ? $rule['list'] : [],
// ['$permissions' => (isset($document['$permissions'])) ? $document['$permissions'] : []]);
$value = $document->getAttribute($key);
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);
break;
}

View file

@ -52,7 +52,7 @@ trait AccountBase
sleep(5);
return [
'uid' => $id,
'id' => $id,
'email' => $email,
'password' => $password,
'name' => $name,
@ -702,7 +702,7 @@ trait AccountBase
*/
public function testUpdateAccountVerification($data):array
{
$id = (isset($data['uid'])) ? $data['uid'] : '';
$id = (isset($data['id'])) ? $data['id'] : '';
$session = (isset($data['session'])) ? $data['session'] : '';
$verification = (isset($data['verification'])) ? $data['verification'] : '';
@ -772,7 +772,7 @@ trait AccountBase
'password' => $password,
]);
$sessionNewUid = $response['body']['$id'];
$sessionNewId = $response['body']['$id'];
$sessionNew = $this->client->parseCookie($response['headers']['set-cookie'])['a_session_'.$this->getProject()['$id']];
$this->assertEquals($response['headers']['status-code'], 201);
@ -786,7 +786,7 @@ trait AccountBase
$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',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -1005,7 +1005,7 @@ trait AccountBase
*/
public function testUpdateAccountRecovery($data):array
{
$id = (isset($data['uid'])) ? $data['uid'] : '';
$id = (isset($data['id'])) ? $data['id'] : '';
$recovery = (isset($data['recovery'])) ? $data['recovery'] : '';
$newPassowrd = 'test-recovery';