示例#1
0
文件: OAuth.php 项目: zource/zource
 public function isApplicationAuthorized(OAuthApplication $application, $identityId)
 {
     if (!$identityId) {
         return false;
     }
     $qb = $this->entityManager->createQueryBuilder();
     $qb->select('COUNT(e.application)');
     $qb->from(OAuthAuthorizedApplication::class, 'e');
     $qb->join(Identity::class, 'i', 'WITH', 'i.account = e.account');
     $qb->where($qb->expr()->eq('e.application', ':application'));
     $qb->andWhere($qb->expr()->eq('i.id', ':identity'));
     $qb->setParameter(':application', $application->getClientId()->getBytes());
     $qb->setParameter(':identity', Uuid::fromString($identityId)->getBytes());
     return $qb->getQuery()->getSingleScalarResult() == 1;
 }
示例#2
0
 public function createApplicationFromArray(AccountInterface $account, array $data)
 {
     $clientSecret = Rand::getString(64, 'abcdefghijklmnopqrstuvwxyz0123456789');
     $oauthApplication = new OAuthApplication($data['name'], $data['homepage']);
     $oauthApplication->setAccount($account);
     $oauthApplication->setClientSecret($this->crypter->create($clientSecret));
     $oauthApplication->setDescription($data['description']);
     $oauthApplication->setRedirectUri($data['redirectUri']);
     $this->persistApplication($oauthApplication);
     return $clientSecret;
 }