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

This commit is contained in:
Eldad Fux committed 2020-06-28 23:56:11 +03:00
commit 0804526ee4
15 files changed
+104 -124

No files matched your search

+1 -1
View File
@@ -138,7 +138,7 @@ abstract class OAuth2
\curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
\curl_setopt($ch, CURLOPT_HEADER, 0);
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, CURLOPT_USERAGENT, '');
\curl_setopt($ch, CURLOPT_USERAGENT, 'Appwrite OAuth2');
if (!empty($payload)) {
\curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
@@ -15,7 +15,7 @@ class Github extends OAuth2
* @var array
*/
protected $scopes = [
'user:email'
'user:email',
];
/**
@@ -78,6 +78,7 @@ class Github extends OAuth2
{
$user = $this->getUser($accessToken);
var_dump($user);
if (isset($user['id'])) {
return $user['id'];
}
@@ -125,7 +126,7 @@ class Github extends OAuth2
* @return array
*/
protected function getUser(string $accessToken)
{
{
if (empty($this->user)) {
$this->user = \json_decode($this->request('GET', 'https://api.github.com/user', ['Authorization: token '.\urlencode($accessToken)]), true);
}
+22 -10
View File
@@ -130,8 +130,6 @@ class Database
'orderField' => '$id',
'orderType' => 'ASC',
'orderCast' => 'int',
'first' => false,
'last' => false,
'filters' => [],
], $options);
@@ -141,17 +139,31 @@ class Database
$node = new Document($node);
}
if ($options['first']) {
$results = \reset($results);
}
if ($options['last']) {
$results = \end($results);
}
return $results;
}
/**
* @param array $options
*
* @return Document
*/
public function getCollectionFirst(array $options)
{
$results = $this->getCollection($options);
return \reset($results);
}
/**
* @param array $options
*
* @return Document
*/
public function getCollectionLast(array $options)
{
$results = $this->getCollection($options);
return \end($results);
}
/**
* @param int $id
* @param bool $mock is mocked data allowed?