Validation and (.) support
Added validation for the username in the install proces. Added dot (.) to the list of allowed symbols.pull/512/head
parent
50ab06640e
commit
e590022cf8
|
@ -244,6 +244,7 @@ class InstallController extends AbstractController {
|
||||||
} else {
|
} else {
|
||||||
// validate the lot
|
// validate the lot
|
||||||
try {
|
try {
|
||||||
|
$validator->username_new($new_user['user_name']);
|
||||||
$validator->email($new_user['email']);
|
$validator->email($new_user['email']);
|
||||||
$validator->password($new_user['password'], $new_user['password_repeat']);
|
$validator->password($new_user['password'], $new_user['password_repeat']);
|
||||||
} catch(\InvalidArgumentException $e) {
|
} catch(\InvalidArgumentException $e) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ class UserValidator {
|
||||||
if(strlen($username) > 64 || strlen($username) < 2) {
|
if(strlen($username) > 64 || strlen($username) < 2) {
|
||||||
throw new \InvalidArgumentException('user_name_bad_length');
|
throw new \InvalidArgumentException('user_name_bad_length');
|
||||||
}
|
}
|
||||||
if (!preg_match('/^[a-zA-Z\d_]{2,64}$/i', $username)) {
|
if (!preg_match('/^[a-zA-Z\d_\.]{2,64}$/i', $username)) {
|
||||||
throw new \InvalidArgumentException('user_name_invalid');
|
throw new \InvalidArgumentException('user_name_invalid');
|
||||||
}
|
}
|
||||||
$user_exists = $this->user->getUserByUsername($username);
|
$user_exists = $this->user->getUserByUsername($username);
|
||||||
|
@ -107,11 +107,30 @@ class UserValidator {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check email
|
* Install only; Check username on:
|
||||||
* @param string $email
|
*
|
||||||
* @return boolean
|
* - Length (2-64 chars)
|
||||||
* @throws \InvalidArgumentException
|
* - Contents (alphabetic chars and digits only)
|
||||||
*/
|
* @param string $username
|
||||||
|
* @return boolean
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function username_new($username) {
|
||||||
|
if(strlen($username) > 64 || strlen($username) < 2) {
|
||||||
|
throw new \InvalidArgumentException('user_name_bad_length');
|
||||||
|
}
|
||||||
|
if (!preg_match('/^[a-zA-Z\d_\.]{2,64}$/i', $username)) {
|
||||||
|
throw new \InvalidArgumentException('user_name_invalid');
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check email
|
||||||
|
* @param string $email
|
||||||
|
* @return boolean
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*/
|
||||||
public function email($email) {
|
public function email($email) {
|
||||||
if(strlen($email) > 255 || strlen($email) < 5) {
|
if(strlen($email) > 255 || strlen($email) < 5) {
|
||||||
throw new \InvalidArgumentException('user_email_bad_length');
|
throw new \InvalidArgumentException('user_email_bad_length');
|
||||||
|
|
Loading…
Reference in New Issue