diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-04-23 22:28:36 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-04-23 22:39:31 +0200 |
commit | f45496336f5bbd31b69553fcfae9cdfd03b280cc (patch) | |
tree | cd085115f041cf0e56a5c5a23dd2706160f2950d /src/Wallabag/CoreBundle/GuzzleSiteAuthenticator | |
parent | bfd69c74e5b4f2ebfcb304b1983bf771c2bb11f7 (diff) | |
download | wallabag-f45496336f5bbd31b69553fcfae9cdfd03b280cc.tar.gz wallabag-f45496336f5bbd31b69553fcfae9cdfd03b280cc.tar.zst wallabag-f45496336f5bbd31b69553fcfae9cdfd03b280cc.zip |
Add ability to match many domains for credentials
Instead of fetching one domain, we use the same method as in site config (to retrieve the matching file) and handle api.example.org, example.org, .org (yes the last one isn’t useful).
If one of these match, we got it and use it.
Diffstat (limited to 'src/Wallabag/CoreBundle/GuzzleSiteAuthenticator')
-rw-r--r-- | src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php index 90e00c62..718441bd 100644 --- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php +++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php | |||
@@ -64,7 +64,17 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder | |||
64 | 64 | ||
65 | $credentials = null; | 65 | $credentials = null; |
66 | if ($this->currentUser) { | 66 | if ($this->currentUser) { |
67 | $credentials = $this->credentialRepository->findOneByHostAndUser($host, $this->currentUser->getId()); | 67 | $hosts = [$host]; |
68 | // will try to see for a host without the first subdomain (fr.example.org & .example.org) | ||
69 | $split = explode('.', $host); | ||
70 | |||
71 | if (\count($split) > 1) { | ||
72 | // remove first subdomain | ||
73 | array_shift($split); | ||
74 | $hosts[] = '.' . implode('.', $split); | ||
75 | } | ||
76 | |||
77 | $credentials = $this->credentialRepository->findOneByHostsAndUser($hosts, $this->currentUser->getId()); | ||
68 | } | 78 | } |
69 | 79 | ||
70 | if (null === $credentials) { | 80 | if (null === $credentials) { |