]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php
Add ability to match many domains for credentials
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Repository / SiteCredentialRepository.php
index b2e212a41438cc32d7e3bbab212aed78382b76fd..aeadd77045a00af2a8dd104ca1461309c8c8fe08 100644 (file)
@@ -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()