Merge branch '1.4.x' of github.com:appwrite/appwrite into disallow-personal-data

This commit is contained in:
Christy Jacob committed 2023-07-20 01:44:25 +04:00
commit e493551f8a
194 files changed
+701 -107

No files matched your search

+6 -3
View File
@@ -456,13 +456,16 @@ class Auth
}
}
foreach ($user->getAttribute('labels', []) as $label) {
$roles[] = 'label:' . $label;
}
return $roles;
}
public static function isAnonymousUser(Document $user): bool
{
return (is_null($user->getAttribute('email'))
|| is_null($user->getAttribute('phone'))
) && is_null($user->getAttribute('password'));
return is_null($user->getAttribute('email'))
&& is_null($user->getAttribute('phone'));
}
}
+2
View File
@@ -84,6 +84,7 @@ class Exception extends \Exception
public const TEAM_INVALID_SECRET = 'team_invalid_secret';
public const TEAM_MEMBERSHIP_MISMATCH = 'team_membership_mismatch';
public const TEAM_INVITE_MISMATCH = 'team_invite_mismatch';
public const TEAM_ALREADY_EXISTS = 'team_already_exists';
/** Membership */
public const MEMBERSHIP_NOT_FOUND = 'membership_not_found';
@@ -135,6 +136,7 @@ class Exception extends \Exception
/** Documents */
public const DOCUMENT_NOT_FOUND = 'document_not_found';
public const DOCUMENT_INVALID_STRUCTURE = 'document_invalid_structure';
public const DOCUMENT_MISSING_DATA = 'document_missing_data';
public const DOCUMENT_MISSING_PAYLOAD = 'document_missing_payload';
public const DOCUMENT_ALREADY_EXISTS = 'document_already_exists';
public const DOCUMENT_UPDATE_CONFLICT = 'document_update_conflict';
@@ -0,0 +1,56 @@
<?php
namespace Appwrite\Utopia\Database\Validator;
use Utopia\Validator;
class ProjectId extends Validator
{
/**
* Is valid.
*
* Returns true if valid or false if not.
*
* @param $value
*
* @return bool
*/
public function isValid($value): bool
{
return $value == 'unique()' || preg_match('/^[a-z0-9][a-z0-9-]{1,35}$/', $value);
}
/**
* Get description.
*
* @return string
*/
public function getDescription(): string
{
return 'Project IDs must contain at most 36 chars. Valid chars are a-z, 0-9, and hyphen. Can\'t start with a special char.';
}
/**
* Is array
*
* Function will return true if object is array.
*
* @return bool
*/
public function isArray(): bool
{
return false;
}
/**
* Get Type
*
* Returns validator type.
*
* @return string
*/
public function getType(): string
{
return self::TYPE_STRING;
}
}
@@ -80,7 +80,7 @@ class Membership extends Model
'type' => self::TYPE_STRING,
'description' => 'User list of roles',
'default' => [],
'example' => 'admin',
'example' => ['owner'],
'array' => true,
])
;
@@ -77,6 +77,13 @@ class User extends Model
'default' => true,
'example' => true,
])
->addRule('labels', [
'type' => self::TYPE_STRING,
'description' => 'Labels for the user.',
'default' => [],
'example' => ['vip'],
'array' => true,
])
->addRule('passwordUpdate', [
'type' => self::TYPE_DATETIME,
'description' => 'Password update time in ISO 8601 format.',