diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-06-11 23:05:19 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-06-20 16:03:35 +0200 |
commit | 906424c1b6fd884bf2081bfe6dd0b1f9651c2801 (patch) | |
tree | 8ca6896e1279e4d403a7b63c775bde7aa2bcf7ce /src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php | |
parent | 9de9f1e5ceed4ac7ecd27e1cb808e630a831f94b (diff) | |
download | wallabag-906424c1b6fd884bf2081bfe6dd0b1f9651c2801.tar.gz wallabag-906424c1b6fd884bf2081bfe6dd0b1f9651c2801.tar.zst wallabag-906424c1b6fd884bf2081bfe6dd0b1f9651c2801.zip |
Crypt site credential password
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php | 20 |
1 files changed, 19 insertions, 1 deletions
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 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\CoreBundle\Repository; | 3 | namespace Wallabag\CoreBundle\Repository; |
4 | 4 | ||
5 | use Wallabag\CoreBundle\Helper\CryptoProxy; | ||
6 | |||
5 | /** | 7 | /** |
6 | * SiteCredentialRepository. | 8 | * SiteCredentialRepository. |
7 | */ | 9 | */ |
8 | class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository | 10 | class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository |
9 | { | 11 | { |
12 | private $cryptoProxy; | ||
13 | |||
14 | public function setCrypto(CryptoProxy $cryptoProxy) | ||
15 | { | ||
16 | $this->cryptoProxy = $cryptoProxy; | ||
17 | } | ||
18 | |||
10 | /** | 19 | /** |
11 | * Retrieve one username/password for the given host and userId. | 20 | * Retrieve one username/password for the given host and userId. |
12 | * | 21 | * |
@@ -17,12 +26,21 @@ class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository | |||
17 | */ | 26 | */ |
18 | public function findOneByHostAndUser($host, $userId) | 27 | public function findOneByHostAndUser($host, $userId) |
19 | { | 28 | { |
20 | return $this->createQueryBuilder('s') | 29 | $res = $this->createQueryBuilder('s') |
21 | ->select('s.username', 's.password') | 30 | ->select('s.username', 's.password') |
22 | ->where('s.host = :hostname')->setParameter('hostname', $host) | 31 | ->where('s.host = :hostname')->setParameter('hostname', $host) |
23 | ->andWhere('s.user = :userId')->setParameter('userId', $userId) | 32 | ->andWhere('s.user = :userId')->setParameter('userId', $userId) |
24 | ->setMaxResults(1) | 33 | ->setMaxResults(1) |
25 | ->getQuery() | 34 | ->getQuery() |
26 | ->getOneOrNullResult(); | 35 | ->getOneOrNullResult(); |
36 | |||
37 | if (null === $res) { | ||
38 | return; | ||
39 | } | ||
40 | |||
41 | // decrypt password before returning it | ||
42 | $res['password'] = $this->cryptoProxy->decrypt($res['password']); | ||
43 | |||
44 | return $res; | ||
27 | } | 45 | } |
28 | } | 46 | } |