Add default implementation for `isEnabled()`
authorCyperghost <olaf_schmitz_1@t-online.de>
Tue, 23 Apr 2024 12:11:41 +0000 (14:11 +0200)
committerCyperghost <olaf_schmitz_1@t-online.de>
Tue, 23 Apr 2024 12:11:41 +0000 (14:11 +0200)
wcfsetup/install/files/lib/action/AbstractOauth2AuthAction.class.php
wcfsetup/install/files/lib/action/FacebookAuthAction.class.php
wcfsetup/install/files/lib/action/GithubAuthAction.class.php
wcfsetup/install/files/lib/action/GoogleAuthAction.class.php
wcfsetup/install/files/lib/action/TwitterAuthAction.class.php

index 878b7d8b8c9c84f58db3936308c10b2aa366e4f3..6bc6628d953bc699386fd401737cc2e83622be45 100644 (file)
@@ -100,7 +100,10 @@ abstract class AbstractOauth2AuthAction implements RequestHandlerInterface
     /**
      * Returns whether this OAuth provider is enabled.
      */
-    abstract protected function isEnabled(): bool;
+    protected function isEnabled(): bool
+    {
+        return !empty($this->getClientId()) && !empty($this->getClientSecret());
+    }
 
     protected function mapParameters(ServerRequestInterface $request): OAuth2Success | OAuth2Failure | null
     {
index 627418adeb85fd2c7040b632ef6d1b2445681a36..712c160d4be2f921645555c11978c514075f9455 100644 (file)
@@ -17,12 +17,6 @@ use wcf\util\StringUtil;
  */
 final class FacebookAuthAction extends AbstractOauth2AuthAction
 {
-    #[\Override]
-    protected function isEnabled(): bool
-    {
-        return !empty(FACEBOOK_PUBLIC_KEY) && !empty(FACEBOOK_PRIVATE_KEY);
-    }
-
     #[\Override]
     protected function getTokenEndpoint(): string
     {
index cf01aca6f3c406e75ae3bffbbe37fe8a834232b8..9b0e77d4294fee8dedcdac6a548354506c4a4636 100644 (file)
@@ -26,12 +26,6 @@ final class GithubAuthAction extends AbstractOauth2AuthAction
         return 'https://github.com/login/oauth/access_token';
     }
 
-    #[\Override]
-    public function isEnabled(): bool
-    {
-        return !empty(GITHUB_PUBLIC_KEY) && !empty(GITHUB_PRIVATE_KEY);
-    }
-
     #[\Override]
     protected function getClientId(): string
     {
index 0b4e9bb03da41e4f44aeb9410391c4dba6703bf1..105abef8d7ba5dffbcc0b1a9d7160e93aadbfec0 100644 (file)
@@ -34,12 +34,6 @@ final class GoogleAuthAction extends AbstractOauth2AuthAction
         return $this->configuration;
     }
 
-    #[\Override]
-    protected function isEnabled(): bool
-    {
-        return !empty(GOOGLE_PUBLIC_KEY) && !empty(GOOGLE_PRIVATE_KEY);
-    }
-
     #[\Override]
     protected function getTokenEndpoint(): string
     {
index ebcc2fbf280c78bc82bab9315bbe5e35ef86d8bb..a89da37c24a989e4c7e630be7f546bc5d6604fd2 100644 (file)
@@ -29,12 +29,6 @@ use wcf\util\StringUtil;
  */
 final class TwitterAuthAction extends AbstractOauth2AuthAction
 {
-    #[\Override]
-    protected function isEnabled(): bool
-    {
-        return !empty(TWITTER_PUBLIC_KEY) && !empty(TWITTER_PRIVATE_KEY);
-    }
-
     #[\Override]
     protected function getClientId(): string
     {