示例#1
0
 public function createAction()
 {
     $this->allow_admin();
     $user = $this->em->getRepository('ZfcUser\\Entity\\User')->findBy(array('email' => $_GET['user']['email']));
     if (!$user) {
         $options = $this->getServiceLocator()->get('zfcuser_module_options');
         $this->bcrypt = new Bcrypt();
         $this->bcrypt->setCost($options->getPasswordCost());
         $cryptPassword = $this->bcrypt->create($_GET['user']['password']);
         $user = new User();
         $user->setUsername($_GET['user']['username']);
         $user->setEmail($_GET['user']['email']);
         $user->setPassword($cryptPassword);
         $this->em->persist($user);
         $this->em->flush();
         $profile = new Profile();
         $profile->setEmail($_GET['user']['email']);
         $profile->setResource($_GET['profile']['type']);
         $this->em->persist($profile);
         $this->em->flush();
         $return = array("id" => $_GET['user']['email'], 'is_success' => 1, "flash" => "Usuario ha sido creado");
     } else {
         $return = array('invalid_form' => 1, 'error_list' => array("Ya existe:" . $_GET['user']['email']));
     }
     return new JsonModel($return);
 }
示例#2
0
 public function providerTestFindBy()
 {
     $user = new Entity();
     $user->setEmail('*****@*****.**');
     $user->setUsername('zfc-user');
     $user->setDisplayName('Zfc-User');
     $user->setId('1');
     $user->setState(1);
     $user->setPassword('zfc-user');
     return array(array('findByEmail', array($user->getEmail()), array('whereArgs' => array(array('email' => $user->getEmail()), 'AND')), array(), $user), array('findByUsername', array($user->getUsername()), array('whereArgs' => array(array('username' => $user->getUsername()), 'AND')), array(), $user), array('findById', array($user->getId()), array('whereArgs' => array(array('user_id' => $user->getId()), 'AND')), array(), $user));
 }