This commit is contained in:
Bruno Rybársky 2024-02-03 17:15:21 +01:00
parent 8073d6c29e
commit 6753603ecd

@ -105,19 +105,17 @@ function doLogin($email, $password): array
$lastLoginAt = null; $lastLoginAt = null;
$loginCount = 0; $loginCount = 0;
$stmt->bind_result($uid, $first_name, $last_name, $nickname, $password_hash, $minecraft_nickname, $privilege_level, $lastLoginAt, $loginCount); $stmt->bind_result($uid, $first_name, $last_name, $nickname, $password_hash, $minecraft_nickname, $privilege_level, $lastLoginAt, $loginCount);
$stmt->fetch();
if ($stmt->num_rows() > 0) { echo "user found";
echo "user found"; if (password_verify($password, $password_hash)) {
$stmt->fetch(); $found = true;
if (password_verify($password, $password_hash)) {
$found = true;
// Update LastLoginAt and LoginCount // Update LastLoginAt and LoginCount
$updateLoginStmt = $mysqli->prepare("UPDATE Users SET LastLoginAt = NOW(), LoginCount = LoginCount + 1 WHERE ID = ?"); $updateLoginStmt = $mysqli->prepare("UPDATE Users SET LastLoginAt = NOW(), LoginCount = LoginCount + 1 WHERE ID = ?");
$updateLoginStmt->bind_param("i", $uid); $updateLoginStmt->bind_param("i", $uid);
$updateLoginStmt->execute(); $updateLoginStmt->execute();
$updateLoginStmt->close(); $updateLoginStmt->close();
}
} }
$_SESSION["ID"] = $uid; $_SESSION["ID"] = $uid;