Fix username and password format checks

This commit is contained in:
Miraty 2022-05-20 02:45:12 +02:00
parent 69f16b72ac
commit 7964b86c70

View file

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