Update RegisterValidator.php
This commit is contained in:
parent
48f6cbeef0
commit
30e5f89118
@ -12,7 +12,13 @@ class RegisterValidator
|
||||
{
|
||||
$login = preg_replace('!\s+!', ' ', $login); // remove inner spaces
|
||||
$login = trim($login); // remove outer spaces
|
||||
if ($this->loginIsAllowed($login) && !$this->loginIsMixed($login)) {
|
||||
if (
|
||||
$this->loginIsAllowed($login) &&
|
||||
!$this->loginIsMixed($login) &&
|
||||
mb_strlen($login < 2) &&
|
||||
mb_strlen($login) > 16 &&
|
||||
!strpos("!@#$%^&*()\+|/'\"", $login)
|
||||
) {
|
||||
$this->login = $login;
|
||||
}
|
||||
return $this;
|
||||
@ -47,7 +53,7 @@ class RegisterValidator
|
||||
|
||||
public function setPassword($password, $passwordVerify)
|
||||
{
|
||||
if ($this->password === $passwordVerify) {
|
||||
if ($this->password === $passwordVerify && mb_strlen($password) > 3) {
|
||||
$this->password = md5($password);
|
||||
}
|
||||
return $this;
|
||||
@ -70,26 +76,14 @@ class RegisterValidator
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function verify()
|
||||
public function get()
|
||||
{
|
||||
if (!empty($this->login) && !empty($this->email) && !empty($this->password) && !empty($this->birthday)) {
|
||||
return [
|
||||
'login' => $this->login,
|
||||
'email' => $this->email,
|
||||
'password' => $this->password,
|
||||
'birthday' => $this->birthday,
|
||||
'sex' => $this->sex,
|
||||
];
|
||||
}
|
||||
return [];
|
||||
return [
|
||||
'login' => $this->login,
|
||||
'email' => $this->email,
|
||||
'password' => $this->password,
|
||||
'birthday' => $this->birthday,
|
||||
'sex' => $this->sex,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$rv = new RegisterValidator();
|
||||
$values = $rv
|
||||
->setLogin($login)
|
||||
->setPassword($pass1, $pass2)
|
||||
->setEmail($email)
|
||||
->setBirthday($birthday)
|
||||
->setSex($sex)
|
||||
->verify();
|
||||
|
Loading…
Reference in New Issue
Block a user