예제 #1
0
파일: User.php 프로젝트: nclundsten/ZfcUser
 /**
  * createFromForm
  *
  * @param Form $form
  * @return ZfcUser\Model\User
  */
 public function createFromForm(Form $form)
 {
     $class = ZfcUser::getOption('user_model_class');
     $user = new $class();
     $user->setEmail($form->getValue('email'))->setPassword(Password::hash($form->getValue('password')))->setRegisterIp($_SERVER['REMOTE_ADDR'])->setRegisterTime(new DateTime('now'))->setEnabled(true);
     if (ZfcUser::getOption('require_activation')) {
         $user->setActive(false);
     } else {
         $user->setActive(true);
     }
     if (ZfcUser::getOption('enable_username')) {
         $user->setUsername($form->getValue('username'));
     }
     if (ZfcUser::getOption('enable_display_name')) {
         $user->setDisplayName($form->getValue('display_name'));
     }
     $this->events()->trigger(__FUNCTION__, $this, array('user' => $user, 'form' => $form));
     $this->userMapper->persist($user);
     return $user;
 }
예제 #2
0
 public function createFromForm(Form $form)
 {
     $user = new UserModel();
     $user->setEmail($form->getValue('email'))->setDisplayName($form->getValue('display_name'))->setSalt($this->randomBytes(16))->setPassword($this->hashPassword($form->getValue('password'), $user->getSalt()));
     $userId = $this->getUserMapper()->insert($user);
 }