コード例 #1
0
ファイル: TokenGenerator.php プロジェクト: dstansby/camdram
 protected function generate(User $user, $salt)
 {
     $string = $user->getEmail() . $user->getPassword() . $this->secret . $salt;
     for ($i = 1; $i < 100; $i++) {
         $digest = hash('sha256', $string, true);
     }
     return bin2hex($digest);
 }
コード例 #2
0
ファイル: UserListener.php プロジェクト: dstansby/camdram
 /**
  * Delete any pending access tokens given to this user, and grant access to
  * those resources in turn.
  */
 public function postPersist(User $user, LifecycleEventArgs $event)
 {
     $pending_aces = $this->entityManager->getRepository('ActsCamdramSecurityBundle:PendingAccess')->findByEmail($user->getEmail());
     foreach ($pending_aces as $pending) {
         $ace = new AccessControlEntry();
         $ace->setUser($user)->setEntityId($pending->getRid())->setCreatedAt(new \DateTime())->setGrantedBy($pending->getIssuer())->setGrantedAt(new \DateTime())->setType($pending->getType());
         $this->entityManager->persist($ace);
         $this->entityManager->remove($pending);
     }
     $this->entityManager->flush();
 }
コード例 #3
0
ファイル: OAuthTest.php プロジェクト: dstansby/camdram
 private function login()
 {
     $this->loginUser = new User();
     $this->loginUser->setEmail('*****@*****.**')->setName('Test User 2');
     $factory = $this->client->getKernel()->getContainer()->get('security.encoder_factory');
     $encoder = $factory->getEncoder($this->loginUser);
     $hashed_password = $encoder->encodePassword('password', $this->loginUser->getSalt());
     $this->loginUser->setPassword($hashed_password);
     $em = $this->getEntityManager();
     $em->persist($this->loginUser);
     $em->flush();
     $crawler = $this->userClient->request('GET', '/auth/login');
     $form = $crawler->selectButton('Log in')->form();
     $form->setValues(array('email' => $this->loginUser->getEmail(), 'password' => 'password'));
     $this->userClient->submit($form);
 }