예제 #1
0
파일: User.php 프로젝트: efueger/gewisweb
 /**
  * Constructor
  */
 public function __construct(NewUser $newUser = null)
 {
     $this->roles = new ArrayCollection();
     if (null !== $newUser) {
         $this->lidnr = $newUser->getLidnr();
         $this->email = $newUser->getEmail();
         $this->member = $newUser->getMember();
     }
 }
예제 #2
0
파일: User.php 프로젝트: wsinnema/gewisweb
 /**
  * Activate a user.
  *
  * @param array $data Activation data.
  * @param NewUserModel $newUser The user to create
  *
  * @return boolean
  */
 public function activate($data, NewUserModel $newUser)
 {
     $form = $this->getActivateForm();
     $form->setData($data);
     if (!$form->isValid()) {
         return false;
     }
     $data = $form->getData();
     $bcrypt = $this->sm->get('user_bcrypt');
     // first try to obtain the user
     $user = $this->getUserMapper()->findByLidnr($newUser->getLidnr());
     if (null === $user) {
         // create a new user from this data, and insert it into the database
         $user = new UserModel($newUser);
     }
     $user->setPassword($bcrypt->create($data['password']));
     // this will also save a user with a lost password
     $this->getUserMapper()->createUser($user, $newUser);
     return true;
 }