示例#1
0
 /**
  * Creates User, specially for fixtures
  *
  * @param array $userData
  *
  * @return BackendUser $user
  */
 public function registerFixturesUser(array $userData)
 {
     $user = new BackendUser();
     $user->setEmail($userData['email']);
     $user->setUsername($userData['username']);
     $user->setPlainPassword($userData['password']);
     $user->setEnabled(true);
     $user->setLocked(false);
     $user->setLastLogin(new \DateTime(date('Y-m-d H:i:s')));
     $this->em->persist($user);
     $this->em->flush();
     return $user;
 }
示例#2
0
 /**
  * Is User Authenticated
  *
  * @param BackendUser $user
  */
 protected function loginUser(BackendUser $user)
 {
     $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
     $this->get('security.context')->setToken($token);
     $this->get('session')->set('user_backend', serialize($token));
 }