Merge branch 'master' of https://github.com/appwrite/appwrite into 0.15.x
This commit is contained in:
commit
4bca6c3696
|
@ -3,6 +3,7 @@ tasks:
|
|||
init: |
|
||||
docker compose pull
|
||||
docker compose build
|
||||
docker pull composer
|
||||
command: |
|
||||
docker run --rm --interactive --tty \
|
||||
--volume $PWD:/app \
|
||||
|
|
|
@ -615,6 +615,11 @@ services:
|
|||
container_name: appwrite-redis
|
||||
<<: *x-logging
|
||||
restart: unless-stopped
|
||||
command: >
|
||||
redis-server
|
||||
--maxmemory 512mb
|
||||
--maxmemory-policy allkeys-lru
|
||||
--maxmemory-samples 5
|
||||
networks:
|
||||
- appwrite
|
||||
volumes:
|
||||
|
|
|
@ -671,6 +671,11 @@ services:
|
|||
image: redis:6.2-alpine
|
||||
<<: *x-logging
|
||||
container_name: appwrite-redis
|
||||
command: >
|
||||
redis-server
|
||||
--maxmemory 512mb
|
||||
--maxmemory-policy allkeys-lru
|
||||
--maxmemory-samples 5
|
||||
ports:
|
||||
- "6379:6379"
|
||||
networks:
|
||||
|
|
|
@ -76,126 +76,84 @@ use Appwrite\Auth\OAuth2;
|
|||
|
||||
class [PROVIDER NAME] extends OAuth2
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $endpoint = '[ENDPOINT API URL]';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $scopes = [
|
||||
private string $endpoint = '[ENDPOINT API URL]';
|
||||
protected array $user = [];
|
||||
protected array $tokens = [];
|
||||
protected array $scopes = [
|
||||
// [ARRAY_OF_REQUIRED_SCOPES]
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $user = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $tokens = [];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return '[PROVIDER NAME]';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLoginURL(): string
|
||||
{
|
||||
$url = $this->endpoint . '[LOGIN_URL_STUFF]';
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getTokens(string $code): array
|
||||
{
|
||||
if(empty($this->tokens)) {
|
||||
if (empty($this->tokens)) {
|
||||
// TODO: Fire request to oauth API to generate access_token
|
||||
// Make sure to use '$this->getScopes()' to include all scopes properly
|
||||
$this->tokens = "[FETCH TOKEN RESPONSE]";
|
||||
$this->tokens = ["[FETCH TOKEN RESPONSE]"];
|
||||
}
|
||||
|
||||
return $this->tokens;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $refreshToken
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function refreshTokens(string $refreshToken):array
|
||||
|
||||
public function refreshTokens(string $refreshToken): array
|
||||
{
|
||||
// TODO: Fire request to oauth API to generate access_token using refresh token
|
||||
$this->tokens = "[FETCH TOKEN RESPONSE]";
|
||||
$this->tokens = ["[FETCH TOKEN RESPONSE]"];
|
||||
|
||||
return $this->tokens;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $accessToken
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUserID(string $accessToken): string
|
||||
{
|
||||
$user = $this->getUser($accessToken);
|
||||
|
||||
// TODO: Pick user ID from $user response
|
||||
|
||||
// TODO: Pick user ID from $user response
|
||||
$userId = "[USER ID]";
|
||||
|
||||
|
||||
return $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $accessToken
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUserEmail(string $accessToken): string
|
||||
{
|
||||
$user = $this->getUser($accessToken);
|
||||
|
||||
// TODO: Pick user email from $user response
|
||||
|
||||
// TODO: Pick user email from $user response
|
||||
$userEmail = "[USER EMAIL]";
|
||||
|
||||
|
||||
return $userEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $accessToken
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function isEmailVerified(string $accessToken): bool
|
||||
{
|
||||
$user = $this->getUser($accessToken);
|
||||
|
||||
// TODO: Pick user verification status from $user response
|
||||
$isVerified = "[USER VERIFICATION STATUS]";
|
||||
|
||||
return $isVerified;
|
||||
}
|
||||
|
||||
public function getUserName(string $accessToken): string
|
||||
{
|
||||
$user = $this->getUser($accessToken);
|
||||
|
||||
// TODO: Pick username from $user response
|
||||
|
||||
// TODO: Pick username from $user response
|
||||
$username = "[USERNAME]";
|
||||
|
||||
|
||||
return $username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $accessToken
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getUser(string $accessToken)
|
||||
|
||||
protected function getUser(string $accessToken): array
|
||||
{
|
||||
if (empty($this->user)) {
|
||||
// TODO: Fire request to oauth API to get information about users
|
||||
|
@ -205,6 +163,7 @@ class [PROVIDER NAME] extends OAuth2
|
|||
return $this->user;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
> If you copy this template, make sure to replace all placeholders wrapped like `[THIS]` and to implement everything marked as `TODO:`.
|
||||
|
@ -233,7 +192,7 @@ First of all, commit the changes with the message `Added XXX OAuth2 Provider` an
|
|||
|
||||
## 🤕 Stuck ?
|
||||
|
||||
If you need any help with the contribution, feel free to head over to [our discord channel](https://appwrite.io/discord) and we'll be happy to help you out.
|
||||
If you need any help with the contribution, feel free to head over to [our Discord channel](https://appwrite.io/discord) and we'll be happy to help you out.
|
||||
|
||||
## 😉 Need more freedom
|
||||
|
||||
|
|
|
@ -254,4 +254,4 @@ First of all, commit the changes with the message `Added XXX Runtime` and push i
|
|||
|
||||
## ![face_with_head_bandage](https://github.githubassets.com/images/icons/emoji/unicode/1f915.png) Stuck ?
|
||||
|
||||
If you need any help with the contribution, feel free to head over to [our discord channel](https://appwrite.io/discord) and we'll be happy to help you out.
|
||||
If you need any help with the contribution, feel free to head over to [our Discord channel](https://appwrite.io/discord) and we'll be happy to help you out.
|
||||
|
|
|
@ -179,4 +179,4 @@ If you can see countries names translated, everything works, and you are ready f
|
|||
First of all, commit the changes with the message `Added YYY translations` where `YYY` is the translated language and push it. This will publish a new branch to your forked version of Appwrite. If you visit it at `github.com/YOUR_USERNAME/appwrite`, you will see a new alert saying you are ready to submit a pull request. Follow the steps GitHub provides, and at the end, you will have your pull request submitted.
|
||||
|
||||
## 🤕 Stuck ?
|
||||
If you need any help with the contribution, feel free to head over to [our discord channel](https://appwrite.io/discord) and we'll be happy to help you out.
|
||||
If you need any help with the contribution, feel free to head over to [our Discord channel](https://appwrite.io/discord) and we'll be happy to help you out.
|
||||
|
|
Loading…
Reference in a new issue