From f45496336f5bbd31b69553fcfae9cdfd03b280cc Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 23 Apr 2019 22:28:36 +0200 Subject: Add ability to match many domains for credentials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Wallabag/CoreBundle/Repository') 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 /** * Retrieve one username/password for the given host and userId. * - * @param string $host - * @param int $userId + * @param array $hosts An array of host to look for + * @param int $userId * * @return array|null */ - public function findOneByHostAndUser($host, $userId) + public function findOneByHostsAndUser($hosts, $userId) { $res = $this->createQueryBuilder('s') ->select('s.username', 's.password') - ->where('s.host = :hostname')->setParameter('hostname', $host) + ->where('s.host IN (:hosts)')->setParameter('hosts', $hosts) ->andWhere('s.user = :userId')->setParameter('userId', $userId) ->setMaxResults(1) ->getQuery() -- cgit v1.2.3