]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
Adding more tests to cover different scenario
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / GuzzleSiteAuthenticator / GrabySiteConfigBuilder.php
index 718441bd459c60a6944781186a7606e87b7a4806..c7502baccdb6a996597bc5502b8502307d42509c 100644 (file)
@@ -62,21 +62,24 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
             $host = substr($host, 4);
         }
 
-        $credentials = null;
-        if ($this->currentUser) {
-            $hosts = [$host];
-            // will try to see for a host without the first subdomain (fr.example.org & .example.org)
-            $split = explode('.', $host);
-
-            if (\count($split) > 1) {
-                // remove first subdomain
-                array_shift($split);
-                $hosts[] = '.' . implode('.', $split);
-            }
+        if (!$this->currentUser) {
+            $this->logger->debug('Auth: no current user defined.');
+
+            return false;
+        }
+
+        $hosts = [$host];
+        // will try to see for a host without the first subdomain (fr.example.org & .example.org)
+        $split = explode('.', $host);
 
-            $credentials = $this->credentialRepository->findOneByHostsAndUser($hosts, $this->currentUser->getId());
+        if (\count($split) > 1) {
+            // remove first subdomain
+            array_shift($split);
+            $hosts[] = '.' . implode('.', $split);
         }
 
+        $credentials = $this->credentialRepository->findOneByHostsAndUser($hosts, $this->currentUser->getId());
+
         if (null === $credentials) {
             $this->logger->debug('Auth: no credentials available for host.', ['host' => $host]);