]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
Add ability to match many domains for credentials
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / GuzzleSiteAuthenticator / GrabySiteConfigBuilder.php
index 90e00c62d9aaeff353e5f356ec6fcc4703e9d5db..718441bd459c60a6944781186a7606e87b7a4806 100644 (file)
@@ -64,7 +64,17 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
 
         $credentials = null;
         if ($this->currentUser) {
-            $credentials = $this->credentialRepository->findOneByHostAndUser($host, $this->currentUser->getId());
+            $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);
+            }
+
+            $credentials = $this->credentialRepository->findOneByHostsAndUser($hosts, $this->currentUser->getId());
         }
 
         if (null === $credentials) {