aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php')
-rw-r--r--src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
index 90e00c62..b0be2176 100644
--- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
+++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
@@ -34,11 +34,6 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
34 34
35 /** 35 /**
36 * GrabySiteConfigBuilder constructor. 36 * GrabySiteConfigBuilder constructor.
37 *
38 * @param ConfigBuilder $grabyConfigBuilder
39 * @param TokenStorage $token
40 * @param SiteCredentialRepository $credentialRepository
41 * @param LoggerInterface $logger
42 */ 37 */
43 public function __construct(ConfigBuilder $grabyConfigBuilder, TokenStorage $token, SiteCredentialRepository $credentialRepository, LoggerInterface $logger) 38 public function __construct(ConfigBuilder $grabyConfigBuilder, TokenStorage $token, SiteCredentialRepository $credentialRepository, LoggerInterface $logger)
44 { 39 {
@@ -62,11 +57,24 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
62 $host = substr($host, 4); 57 $host = substr($host, 4);
63 } 58 }
64 59
65 $credentials = null; 60 if (!$this->currentUser) {
66 if ($this->currentUser) { 61 $this->logger->debug('Auth: no current user defined.');
67 $credentials = $this->credentialRepository->findOneByHostAndUser($host, $this->currentUser->getId()); 62
63 return false;
68 } 64 }
69 65
66 $hosts = [$host];
67 // will try to see for a host without the first subdomain (fr.example.org & .example.org)
68 $split = explode('.', $host);
69
70 if (\count($split) > 1) {
71 // remove first subdomain
72 array_shift($split);
73 $hosts[] = '.' . implode('.', $split);
74 }
75
76 $credentials = $this->credentialRepository->findOneByHostsAndUser($hosts, $this->currentUser->getId());
77
70 if (null === $credentials) { 78 if (null === $credentials) {
71 $this->logger->debug('Auth: no credentials available for host.', ['host' => $host]); 79 $this->logger->debug('Auth: no credentials available for host.', ['host' => $host]);
72 80