/**
  * @param ApiAccount $account
  * @return ApiOauthToken|null
  */
 public function findDeveloperToken(ApiAccount $account)
 {
     $qb = $this->createQueryBuilder('tok');
     $qb->innerJoin('tok.account', 'acc', Expr\Join::WITH, $qb->expr()->eq('acc.id', ':acc_id'));
     $qb->innerJoin('acc.application', 'app', Expr\Join::WITH, $qb->expr()->orx($qb->expr()->eq('app.creator', 'acc.user'), $qb->expr()->isNull('app.creator')));
     $qb->where($qb->expr()->isNull('tok.expires'));
     $qb->orderBy('tok.created', 'DESC');
     $qb->setParameter(':acc_id', $account->getId());
     /*
      * @note until we add expiration token, there is no way to distinguish a developer issued token from
      * a connection process issued token.
      */
     return $qb->getQuery()->getOneOrNullResult();
 }
Esempio n. 2
0
 /**
  * @param ApiAccount $account
  *
  * @return ApiOauthTokens
  */
 public function setAccount(ApiAccount $account)
 {
     $account->addTokens($this);
     $this->account = $account;
     return $this;
 }
 public function revokeAccess(ApiAccount $account)
 {
     $account->setRevoked(true);
     $this->update($account);
 }