Fix username and password format checks

This commit is contained in:
Miraty 2022-05-20 02:45:12 +02:00
parent 69f16b72ac
commit 7964b86c70
1 changed files with 5 additions and 11 deletions

View File

@ -12,13 +12,13 @@ define("OPTIONS_PASSWORD", array(
)); ));
function checkPasswordFormat($password) { function checkPasswordFormat($password) {
if (preg_match("/" . PASSWORD_REGEX . "/", $password) !== true) if (preg_match("/" . PASSWORD_REGEX . "/", $password) !== 1)
userError("Password malformed.") userError("Password malformed.");
} }
function checkUsernameFormat($username) { function checkUsernameFormat($username) {
if (preg_match("/" . USERNAME_REGEX . "/", $username) !== true) if (preg_match("/" . USERNAME_REGEX . "/", $username) !== 1)
userError("Username malformed.") userError("Username malformed.");
} }
function hashPassword($password) { function hashPassword($password) {
@ -35,15 +35,9 @@ function userExist($username) {
$data = $op->fetch(); $data = $op->fetch();
if (isset($data['username'])) if (isset($data['username']))
$dbUsername = $data['username'];
else
$dbUsername = NULL;
if (isset($dbUsername)) {
return true; return true;
} else { else
return false; return false;
}
} }
function checkPassword($username, $password) { function checkPassword($username, $password) {