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/Repository | |
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/Repository')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php index b2e212a4..aeadd770 100644 --- a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php +++ b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php | |||
@@ -19,16 +19,16 @@ class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository | |||
19 | /** | 19 | /** |
20 | * Retrieve one username/password for the given host and userId. | 20 | * Retrieve one username/password for the given host and userId. |
21 | * | 21 | * |
22 | * @param string $host | 22 | * @param array $hosts An array of host to look for |
23 | * @param int $userId | 23 | * @param int $userId |
24 | * | 24 | * |
25 | * @return array|null | 25 | * @return array|null |
26 | */ | 26 | */ |
27 | public function findOneByHostAndUser($host, $userId) | 27 | public function findOneByHostsAndUser($hosts, $userId) |
28 | { | 28 | { |
29 | $res = $this->createQueryBuilder('s') | 29 | $res = $this->createQueryBuilder('s') |
30 | ->select('s.username', 's.password') | 30 | ->select('s.username', 's.password') |
31 | ->where('s.host = :hostname')->setParameter('hostname', $host) | 31 | ->where('s.host IN (:hosts)')->setParameter('hosts', $hosts) |
32 | ->andWhere('s.user = :userId')->setParameter('userId', $userId) | 32 | ->andWhere('s.user = :userId')->setParameter('userId', $userId) |
33 | ->setMaxResults(1) | 33 | ->setMaxResults(1) |
34 | ->getQuery() | 34 | ->getQuery() |