diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-05-01 22:13:17 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-06-20 16:03:13 +0200 |
commit | 5a9bc00726ddaf7c8798d4932d0a8b7a38422670 (patch) | |
tree | 487a36da4997b305da9113985785fdf7e97c1811 /src/Wallabag/CoreBundle/Repository | |
parent | fc6d92c63dc5629a9e005628e416e0ecf4daa6ed (diff) | |
download | wallabag-5a9bc00726ddaf7c8798d4932d0a8b7a38422670.tar.gz wallabag-5a9bc00726ddaf7c8798d4932d0a8b7a38422670.tar.zst wallabag-5a9bc00726ddaf7c8798d4932d0a8b7a38422670.zip |
Retrieve username/password from database
Inject the current user & the repo to retrieve username/password from the database
Diffstat (limited to 'src/Wallabag/CoreBundle/Repository')
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php index 88aee6d5..316ecc75 100644 --- a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php +++ b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php | |||
@@ -7,4 +7,22 @@ namespace Wallabag\CoreBundle\Repository; | |||
7 | */ | 7 | */ |
8 | class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository | 8 | class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository |
9 | { | 9 | { |
10 | /** | ||
11 | * Retrieve one username/password for the given host and userId. | ||
12 | * | ||
13 | * @param string $host | ||
14 | * @param int $userId | ||
15 | * | ||
16 | * @return null|array | ||
17 | */ | ||
18 | public function findOneByHostAndUser($host, $userId) | ||
19 | { | ||
20 | return $this->createQueryBuilder('s') | ||
21 | ->select('s.username', 's.password') | ||
22 | ->where('s.host = :hostname')->setParameter('hostname', $host) | ||
23 | ->andWhere('s.user = :userId')->setParameter('userId', $userId) | ||
24 | ->setMaxResults(1) | ||
25 | ->getQuery() | ||
26 | ->getOneOrNullResult(); | ||
27 | } | ||
10 | } | 28 | } |