Merge 120a3d2082
into 72d865e26f
commit
a2e0ece964
|
@ -21,7 +21,7 @@
|
||||||
* @author Pepijn Over <pep@mailbox.org>
|
* @author Pepijn Over <pep@mailbox.org>
|
||||||
* @copyright Copyright (c) 2008-2017 Pepijn Over <pep@mailbox.org>
|
* @copyright Copyright (c) 2008-2017 Pepijn Over <pep@mailbox.org>
|
||||||
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||||
* @version Release: @package_version@
|
* @version Release: v3.2.0
|
||||||
* @link http://www.phpservermonitor.org/
|
* @link http://www.phpservermonitor.org/
|
||||||
* @since phpservermon 3.0.0
|
* @since phpservermon 3.0.0
|
||||||
**/
|
**/
|
||||||
|
@ -67,7 +67,7 @@ class UserValidator {
|
||||||
* Check username on:
|
* Check username on:
|
||||||
*
|
*
|
||||||
* - Length (2-64 chars)
|
* - Length (2-64 chars)
|
||||||
* - Contents (alphabetic chars and digits only)
|
* - Contents (alphabetic chars and digits only as well as periods "." as in "adduser --force-badname")
|
||||||
* - Unique
|
* - Unique
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @param int $user_id to check whether the username is unique
|
* @param int $user_id to check whether the username is unique
|
||||||
|
@ -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_\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);
|
||||||
|
@ -106,25 +106,6 @@ class UserValidator {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Install only; Check username on:
|
|
||||||
*
|
|
||||||
* - Length (2-64 chars)
|
|
||||||
* - 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
|
* Check email
|
||||||
* @param string $email
|
* @param string $email
|
||||||
|
|
Loading…
Reference in New Issue