mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
oauth2 providers in project grouped
This commit is contained in:
1 parent
9b25d65c85
commit
475002eef8
7 files changed
+47
-54
No files matched your search
@@ -138,13 +138,13 @@ class Project extends Model
|
||||
$name = (isset($provider['name'])) ? $provider['name'] : 'Unknown';
|
||||
|
||||
$this
|
||||
->addRule('usersOauth2'.\ucfirst($index).'Appid', [
|
||||
->addRule('provider'.\ucfirst($index).'Appid', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => $name.' OAuth app ID.',
|
||||
'example' => '123247283472834787438',
|
||||
'default' => '',
|
||||
])
|
||||
->addRule('usersOauth2'.\ucfirst($index).'Secret', [
|
||||
->addRule('provider'.\ucfirst($index).'Secret', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => $name.' OAuth secret ID.',
|
||||
'example' => 'djsgudsdsewe43434343dd34...',
|
||||
@@ -238,6 +238,18 @@ class Project extends Model
|
||||
$document->setAttribute('auth' . ucfirst($key), $value);
|
||||
}
|
||||
|
||||
$providers = Config::getParam('providers', []);
|
||||
$providerValues = $document->getAttribute('providers', []);
|
||||
|
||||
foreach ($providers as $key => $provider) {
|
||||
if (!$provider['enabled']) {
|
||||
continue;
|
||||
}
|
||||
$appId = $providerValues[$key . 'Appid'] ?? '';
|
||||
$secret = $providerValues[$key . 'Secret'] ?? '';
|
||||
$document->setAttribute($key . 'Appid', $appId)->setAttribute($key . 'Secret', $secret);
|
||||
}
|
||||
|
||||
return $document;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user