From 13686d85dc59c505d4281e3858e98c959919aaf0 Mon Sep 17 00:00:00 2001 From: bruno Date: Thu, 18 Jan 2024 11:53:39 +0100 Subject: [PATCH] fix stupid mistakes --- endpoints/global/account.php | 3 --- lib/account.php | 4 ++-- lib/endpoint.php | 3 +-- pages/global/account.php | 20 -------------------- 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/endpoints/global/account.php b/endpoints/global/account.php index cb776cb..b876429 100644 --- a/endpoints/global/account.php +++ b/endpoints/global/account.php @@ -8,15 +8,12 @@ function endpoint($endpoint_data) case "login": return doLogin($endpoint_data["email"], $endpoint_data["password"]); - break; case "logout": return doLogout(); - break; case "register": return doRegister($endpoint_data["firstname"], $endpoint_data["lastname"], $endpoint_data["nickname"], $endpoint_data["email"], $endpoint_data["password"], $endpoint_data["minecraftnick"], $endpoint_data["activation_token"]); - break; } } \ No newline at end of file diff --git a/lib/account.php b/lib/account.php index f40b553..ce1ef49 100644 --- a/lib/account.php +++ b/lib/account.php @@ -6,6 +6,7 @@ function isLoggedIn(){ function doLogin($email, $password){ global $mysqli; + $found = false; if(!empty($email) && !empty($password)){ $stmt = $mysqli->prepare("SELECT ID, FirstName, LastName, Nickname, PasswordHash, MinecraftNick, isAdmin FROM Users WHERE EMAIL = ? AND isActive = 1"); $stmt->bind_param("s", $email); @@ -19,7 +20,6 @@ function doLogin($email, $password){ $mcnick = ""; $stmt->bind_result($idcko, $fname, $lname, $nickname, $pwdhash, $mcnick, false); - $found = false; if($stmt->num_rows() > 0){ $stmt->fetch(); if (password_verify($password, $pwdhash)){ @@ -34,8 +34,8 @@ function doLogin($email, $password){ } } $stmt->close(); - return $found ? ["status" => "success"] : ["status" => "fail"]; } + return $found ? ["status" => "success"] : ["status" => "fail"]; } function doLogout(){ diff --git a/lib/endpoint.php b/lib/endpoint.php index 8e50f6d..322db3f 100644 --- a/lib/endpoint.php +++ b/lib/endpoint.php @@ -2,9 +2,8 @@ function runEndpoint($endpoint_file) { - global $routerRequest; - $endpoint_data = $_POST + $endpoint_data = $_POST; require_once $endpoint_file; return endpoint($endpoint_data); diff --git a/pages/global/account.php b/pages/global/account.php index a333490..7dddbc9 100644 --- a/pages/global/account.php +++ b/pages/global/account.php @@ -5,26 +5,6 @@ require_once "lib/router.php"; function render() { global $routerConfig; - $diddoAjax = true; - - switch ($_POST["action"]) { - case "login": - doLogin(); - break; - case "register": - doRegister(); - break; - case "logout": - doLogout(); - break; - default: - $diddoAjax = false; - break; - } - - if ($diddoAjax) { - exit(); - } ob_start();