Rename game_session_token to token and rename uid to id
This commit is contained in:
@@ -25,19 +25,17 @@ if (!password_verify($password, $user["password"])) {
|
|||||||
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
exitWithMessage(json_encode(["success" => false, "message" => "Invalid username or password"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$uid = $user['uid'];
|
$id = $user['id'];
|
||||||
$token = $user['game_session_token'];
|
$token = $user['token'];
|
||||||
if (!$token || strlen(trim($token)) !== 512) $token = bin2hex(random_bytes(256));
|
|
||||||
|
|
||||||
$ip = getIPAddress();
|
$ip = getIPAddress();
|
||||||
|
|
||||||
$stmt = $conn->prepare("UPDATE users SET latest_ip = ?, game_session_token = ? WHERE uid = ?");
|
$stmt = $conn->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?");
|
||||||
$stmt->bind_param("ssi", $ip, $token, $uid);
|
$stmt->bind_param("ssi", $ip, $token, $id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
if ($currentHighScore > $user['highScore']) {
|
if ($currentHighScore > $user['highScore']) {
|
||||||
$stmt = $conn->prepare("UPDATE users SET highScore = ? WHERE uid = ?");
|
$stmt = $conn->prepare("UPDATE users SET highScore = ? WHERE id = ?");
|
||||||
$stmt->bind_param("ii", $currentHighScore, $uid);
|
$stmt->bind_param("ii", $currentHighScore, $id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$user['highScore'] = $currentHighScore;
|
$user['highScore'] = $currentHighScore;
|
||||||
}
|
}
|
||||||
@@ -47,7 +45,7 @@ $data = ["session" => $token];
|
|||||||
if ($loginType === "0") {
|
if ($loginType === "0") {
|
||||||
$data += [
|
$data += [
|
||||||
"username" => $user['username'],
|
"username" => $user['username'],
|
||||||
"userid" => $uid,
|
"id" => $id,
|
||||||
"highscore" => (string)$user['highScore'],
|
"highscore" => (string)$user['highScore'],
|
||||||
"icon" => (int)$user['icon'],
|
"icon" => (int)$user['icon'],
|
||||||
"overlay" => (int)$user['overlay'],
|
"overlay" => (int)$user['overlay'],
|
||||||
@@ -63,7 +61,7 @@ if ($loginType === "0") {
|
|||||||
} elseif ($loginType === "1") {
|
} elseif ($loginType === "1") {
|
||||||
$data += [
|
$data += [
|
||||||
"username" => $user['username'],
|
"username" => $user['username'],
|
||||||
"userid" => $uid
|
"id" => $id
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ if (!preg_match('/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_\-+=]{8,}$/', $pass
|
|||||||
exitWithMessage(json_encode(["success" => false, "message" => "Password must be at least 8 characters with at least one letter and one number"]));
|
exitWithMessage(json_encode(["success" => false, "message" => "Password must be at least 8 characters with at least one letter and one number"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $conn->prepare("SELECT uid FROM users WHERE username = ? OR email = ?");
|
$stmt = $conn->prepare("SELECT id FROM users WHERE username = ? OR email = ?");
|
||||||
$stmt->bind_param("ss", $username, $email);
|
$stmt->bind_param("ss", $username, $email);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$res = $stmt->get_result();
|
$res = $stmt->get_result();
|
||||||
@@ -35,7 +35,7 @@ $token = bin2hex(random_bytes(256));
|
|||||||
$ip = getIPAddress();
|
$ip = getIPAddress();
|
||||||
$time = time();
|
$time = time();
|
||||||
|
|
||||||
$stmt = $conn->prepare("INSERT INTO users (game_session_token, username, password, email, register_time, latest_ip) VALUES (?, ?, ?, ?, ?, ?)");
|
$stmt = $conn->prepare("INSERT INTO users (token, username, password, email, register_time, latest_ip) VALUES (?, ?, ?, ?, ?, ?)");
|
||||||
$stmt->bind_param("ssssis", $token, $username, $hashed, $email, $time, $ip);
|
$stmt->bind_param("ssssis", $token, $username, $hashed, $email, $time, $ip);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user