Skip to content

Commit db87728

Browse files
committed
chore: don't cache the oauth config if we're in debug mode
1 parent 380efc5 commit db87728

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/OAuthServiceProvider.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace FoF\OAuth;
1313

1414
use Flarum\Foundation\AbstractServiceProvider;
15+
use Flarum\Foundation\Config;
1516
use Flarum\Http\RouteCollection;
1617
use Flarum\Http\RouteHandlerFactory;
1718
use Illuminate\Contracts\Cache\Store as Cache;
@@ -44,8 +45,15 @@ public function boot()
4445
{
4546
/** @var Cache $cache */
4647
$cache = $this->container->make(Cache::class);
48+
/** @var Config $config */
49+
$config = $this->container->make(Config::class);
50+
51+
$this->container->singleton('fof-oauth.providers.forum', function () use ($cache, $config) {
52+
// If we're in debug mode, don't cache the providers, but directly return them.
53+
if ($config->inDebugMode()) {
54+
return $this->mapProviders();
55+
}
4756

48-
$this->container->singleton('fof-oauth.providers.forum', function () use ($cache) {
4957
$cacheKey = 'fof-oauth.providers.forum';
5058

5159
$data = $cache->get($cacheKey);
@@ -57,7 +65,12 @@ public function boot()
5765
return $data;
5866
});
5967

60-
$this->container->singleton('fof-oauth.providers.admin', function () use ($cache) {
68+
$this->container->singleton('fof-oauth.providers.admin', function () use ($cache, $config) {
69+
// If we're in debug mode, don't cache the providers, but directly return them.
70+
if ($config->inDebugMode()) {
71+
return $this->mapProviders();
72+
}
73+
6174
$cacheKey = 'fof-oauth.providers.admin';
6275

6376
$data = $cache->get($cacheKey);

0 commit comments

Comments
 (0)