Commit 47de6732 authored by Pål Karlsrud's avatar Pål Karlsrud

Make it easier to preconfigure the different providers.

parent 83870675
......@@ -52,9 +52,22 @@ class Application extends App
$request = $this->query(IRequest::class);
$this->redirectUrl = $request->getParam('redirect_url');
$providers = json_decode($this->config->getAppValue($this->appName, 'oauth_providers', '[]'), true);
$providersJson = $this->config->getAppValue($this->appName, 'oauth_providers', '[]');
$providers = json_decode($providersJson, true);
if (is_array($providers)) {
// If the admin has preconfigured providers, add them to the database (if they are not already there).
$preconfiguredProviders = $this->config->getSystemValue('social_login_oauth_providers', []);
foreach ($preconfiguredProviders as $name => $provider) {
$providers[$name] = $preconfiguredProviders[$name];
}
$newProvidersJson = json_encode($providers);
if ($newProvidersJson !== $providersJson) {
$this->config->setAppValue($this->appName, 'oauth_providers', $newProvidersJson);
}
foreach ($providers as $name => $provider) {
if ($provider['appid']) {
++$this->providersCount;
$this->providerUrl = $this->urlGenerator->linkToRoute($this->appName.'.login.oauth', [
......
......@@ -92,6 +92,12 @@ class LoginController extends Controller
];
$config = [];
$providers = json_decode($this->config->getAppValue($this->appName, 'oauth_providers', '[]'), true);
foreach ($providers as $name => $prov) {
if(isset($prov['scope'])) {
$scopes[$name] = $prov['scope'];
}
}
if (is_array($providers) && in_array($provider, array_keys($providers))) {
foreach ($providers as $name => $prov) {
if ($name === $provider) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment