Merge branch 'master' of github.com:appwrite/appwrite into 0.9.x

This commit is contained in:
Eldad Fux 2021-07-03 09:21:07 +03:00
commit 57bc8c75e0
12 changed files with 6161 additions and 1530 deletions

View File

@ -16,7 +16,7 @@ FROM php:8.0-cli-alpine as step1
ENV PHP_REDIS_VERSION=5.3.4 \
PHP_SWOOLE_VERSION=v4.6.7 \
PHP_IMAGICK_VERSION=master \
PHP_IMAGICK_VERSION=3.5.0 \
PHP_YAML_VERSION=2.2.1 \
PHP_MAXMINDDB_VERSION=v1.10.1
@ -53,10 +53,8 @@ RUN \
make && make install && \
cd .. && \
## Imagick Extension
## Last working commit https://github.com/Imagick/imagick/commit/35741750aa1cda2b7ac354bfa6128fa037e9cf32
git clone --branch $PHP_IMAGICK_VERSION https://github.com/Imagick/imagick && \
git clone --depth 1 --branch $PHP_IMAGICK_VERSION https://github.com/imagick/imagick && \
cd imagick && \
git checkout 35741750aa1cda2b7ac354bfa6128fa037e9cf32 && \
phpize && \
./configure && \
make && make install && \
@ -152,10 +150,12 @@ RUN \
brotli-dev \
yaml-dev \
imagemagick \
imagemagick-dev \
libmaxminddb-dev \
certbot \
docker-cli \
docker-compose \
libgomp \
&& docker-php-ext-install sockets opcache pdo_mysql \
&& apk del .deps \
&& rm -rf /var/cache/apk/*

View File

@ -1155,14 +1155,23 @@ App::patch('/v1/account/email')
// TODO after this user needs to confirm mail again
$user = $projectDB->updateDocument(\array_merge(
if (!$isAnonymousUser) {
// Remove previous unique ID.
$projectDB->deleteUniqueKey(\md5($user->getArrayCopy()['$collection'].':'.'email'.'='.$user->getAttribute('email')));
}
$document = (\array_merge(
$user->getArrayCopy(),
($isAnonymousUser ? [ 'password' => Auth::passwordHash($password) ] : []),
[
'email' => $email,
'emailVerification' => false,
]
));
));
$user = $projectDB->updateDocument($document);
$projectDB->addUniqueKey(\md5($document['$collection'].':'.'email'.'='.$email));
if (false === $user) {
throw new Exception('Failed saving user to DB', 500);

View File

@ -22,7 +22,6 @@ use Utopia\Image\Image;
use Appwrite\OpenSSL\OpenSSL;
use Appwrite\Utopia\Response;
use Utopia\Config\Config;
use Utopia\Validator\Numeric;
App::post('/v1/storage/files')
->desc('Create File')

View File

@ -7,7 +7,7 @@ use Appwrite\Network\Validator\Host;
use Appwrite\Utopia\Response;
use Utopia\App;
use Utopia\Validator\ArrayList;
use Utopia\Validator\Integer;
use Utopia\Validator\Numeric;
use Utopia\Validator\Text;
use Utopia\Storage\Validator\File;
@ -24,7 +24,7 @@ App::get('/v1/mock/tests/foo')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -42,7 +42,7 @@ App::post('/v1/mock/tests/foo')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -60,7 +60,7 @@ App::patch('/v1/mock/tests/foo')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -78,7 +78,7 @@ App::put('/v1/mock/tests/foo')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -96,7 +96,7 @@ App::delete('/v1/mock/tests/foo')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -114,7 +114,7 @@ App::get('/v1/mock/tests/bar')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -132,7 +132,7 @@ App::post('/v1/mock/tests/bar')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -150,7 +150,7 @@ App::patch('/v1/mock/tests/bar')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -168,7 +168,7 @@ App::put('/v1/mock/tests/bar')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -186,7 +186,7 @@ App::delete('/v1/mock/tests/bar')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->action(function ($x, $y, $z) {
});
@ -230,7 +230,7 @@ App::post('/v1/mock/tests/general/upload')
->label('sdk.response.model', Response::MODEL_MOCK)
->label('sdk.mock', true)
->param('x', '', new Text(100), 'Sample string param')
->param('y', '', new Integer(), 'Sample numeric param')
->param('y', '', new Numeric(), 'Sample numeric param')
->param('z', null, new ArrayList(new Text(256)), 'Sample array param')
->param('file', [], new File(), 'Sample file param', false)
->inject('request')

View File

@ -1 +1,3 @@
Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed.
Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed.
If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user..

7549
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,6 @@
"gulp-clean-css": "^4.3.0",
"gulp-concat": "^2.6.1",
"gulp-jsmin": "^0.1.5",
"gulp-less": "^4.0.1",
"ls-service-form2json": "^1.0.0",
"yargs-parser": "^20.2.7"
"gulp-less": "^5.0.0"
}
}

View File

@ -91,12 +91,21 @@ abstract class Adapter
/**
* Delete Unique Key.
*
* @param int $key
* @param string $key
*
* @return array
*/
abstract public function deleteUniqueKey($key);
/**
* Add Unique Key.
*
* @param string $key
*
* @return array
*/
abstract public function addUniqueKey($key);
/**
* Create Namespace.
*

View File

@ -366,7 +366,7 @@ class MySQL extends Adapter
/**
* Delete Unique Key.
*
* @param int $key
* @param string $key
*
* @return array
*
@ -383,6 +383,30 @@ class MySQL extends Adapter
return [];
}
/**
* Add Unique Key.
*
* @param string $key
*
* @return array
*
* @throws Exception
*/
public function addUniqueKey($key)
{
$st = $this->getPDO()->prepare('INSERT INTO `'.$this->getNamespace().'.database.unique`
SET `key` = :key;
');
$st->bindValue(':key', $key, PDO::PARAM_STR);
if (!$st->execute()) {
throw new Duplicate('Duplicated Property: '.$key);
}
return [];
}
/**
* Create Relation.
*

View File

@ -168,6 +168,22 @@ class Redis extends Adapter
return $data;
}
/**
* Add Unique Key.
*
* @param $key
*
* @return array
*
* @throws Exception
*/
public function addUniqueKey($key)
{
$data = $this->adapter->addUniqueKey($key);
return $data;
}
/**
* Create Namespace.
*

View File

@ -370,6 +370,18 @@ class Database
return new Document($this->adapter->deleteUniqueKey($key));
}
/**
* @param int $key
*
* @return Document|false
*
* @throws AuthorizationException
*/
public function addUniqueKey($key)
{
return new Document($this->adapter->addUniqueKey($key));
}
/**
* @return array
*/

View File

@ -591,6 +591,29 @@ trait AccountBase
$this->assertEquals($response['headers']['status-code'], 400);
// Test if we can create a new account with the old email
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => $data['email'],
'password' => $data['password'],
'name' => $data['name'],
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertIsNumeric($response['body']['registration']);
$this->assertEquals($response['body']['email'], $data['email']);
$this->assertEquals($response['body']['name'], $data['name'],);
$data['email'] = $newEmail;
return $data;