Browse Source

Fix username and password format checks

Miraty 3 years ago
parent
commit
7964b86c70
1 changed files with 5 additions and 11 deletions
  1. 5 11
      auth.php

+ 5 - 11
auth.php

@@ -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) {