示例#1
0
 private function validateNewPassword($password)
 {
     try {
         Security\Passwords::validateNew($password);
         return true;
     } catch (Nette\UnexpectedValueException $ex) {
         throw BadRequestException::unprocessableEntity(array($ex->getMessage), 'Bad format of new password.');
     }
 }
示例#2
0
 /**
  * Adds new user.
  * @param  string
  * @param  string
  * @return void
  */
 public function add($username, $email, $password)
 {
     Passwords::validateNew($password);
     try {
         $this->db->table(static::TABLE_NAME)->insert(array(static::COLUMN_NAME => $username, static::COLUMN_EMAIL => $email, static::COLUMN_PASSWORD_HASH => Security\Passwords::hash($password)));
     } catch (Database\UniqueConstraintViolationException $e) {
         throw new DuplicateNameException();
     }
 }