X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FRepository%2FSiteCredentialRepository.php;h=6f904f0ae86b2c8cc7e8236378e7e2f92578243a;hb=906424c1b6fd884bf2081bfe6dd0b1f9651c2801;hp=316ecc75020e5400ef272a7e97664a50b6aa8910;hpb=9de9f1e5ceed4ac7ecd27e1cb808e630a831f94b;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php index 316ecc75..6f904f0a 100644 --- a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php +++ b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php @@ -2,11 +2,20 @@ namespace Wallabag\CoreBundle\Repository; +use Wallabag\CoreBundle\Helper\CryptoProxy; + /** * SiteCredentialRepository. */ class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository { + private $cryptoProxy; + + public function setCrypto(CryptoProxy $cryptoProxy) + { + $this->cryptoProxy = $cryptoProxy; + } + /** * Retrieve one username/password for the given host and userId. * @@ -17,12 +26,21 @@ class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository */ public function findOneByHostAndUser($host, $userId) { - return $this->createQueryBuilder('s') + $res = $this->createQueryBuilder('s') ->select('s.username', 's.password') ->where('s.host = :hostname')->setParameter('hostname', $host) ->andWhere('s.user = :userId')->setParameter('userId', $userId) ->setMaxResults(1) ->getQuery() ->getOneOrNullResult(); + + if (null === $res) { + return; + } + + // decrypt password before returning it + $res['password'] = $this->cryptoProxy->decrypt($res['password']); + + return $res; } }