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.'); } }
/** * 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(); } }