mirror of
https://github.com/wallabag/wallabag.git
synced 2025-10-20 19:52:09 +00:00
Retrieve username/password from database
Inject the current user & the repo to retrieve username/password from the database
This commit is contained in:
parent
fc6d92c63d
commit
5a9bc00726
4 changed files with 49 additions and 13 deletions
|
@ -7,4 +7,22 @@ namespace Wallabag\CoreBundle\Repository;
|
|||
*/
|
||||
class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository
|
||||
{
|
||||
/**
|
||||
* Retrieve one username/password for the given host and userId.
|
||||
*
|
||||
* @param string $host
|
||||
* @param int $userId
|
||||
*
|
||||
* @return null|array
|
||||
*/
|
||||
public function findOneByHostAndUser($host, $userId)
|
||||
{
|
||||
return $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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue