oauth2 providers in project grouped

This commit is contained in:
Damodar Lohani committed 2021-08-06 16:20:50 +05:45
1 parent 9b25d65c85
commit 475002eef8
7 files changed
+47 -54

No files matched your search

+14 -2
View File
@@ -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;
}
}