コード例 #1
0
 /**
  * Adds new user.
  * @param  string
  * @param  string
  * @return void
  */
 public function add($username, $password)
 {
     $user = new Entities\UserEntity();
     $user->setUsername($username);
     $user->setPassword(Passwords::hash($password));
     $this->userRepository->save($user);
 }
コード例 #2
0
ファイル: UserRepository.php プロジェクト: CSHH/website
 /**
  * @param  ArrayHash                             $values
  * @param  Entities\UserEntity                   $user
  * @throws PossibleUniqueKeyDuplicationException
  * @return Entities\UserEntity
  */
 public function updateProfileSettings(ArrayHash $values, Entities\UserEntity $user)
 {
     $pass = $values->password;
     unset($values->password);
     $user->setValues($values);
     $e = $this->isValueDuplicate($this->em, Entities\UserEntity::getClassName(), 'email', $user->email);
     if ($e && $e->id !== $user->id) {
         throw new PossibleUniqueKeyDuplicationException($this->translator->translate('locale.duplicity.registration_email'));
     }
     if ($pass) {
         $user->salt = $this->generateSalt();
         $user->password = Passwords::hash($pass . $user->salt);
     }
     $this->persistAndFlush($this->em, $user);
     return $user;
 }