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"]));
|
||||
}
|
||||
|
||||
$uid = $user['uid'];
|
||||
$token = $user['game_session_token'];
|
||||
if (!$token || strlen(trim($token)) !== 512) $token = bin2hex(random_bytes(256));
|
||||
|
||||
$id = $user['id'];
|
||||
$token = $user['token'];
|
||||
$ip = getIPAddress();
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET latest_ip = ?, game_session_token = ? WHERE uid = ?");
|
||||
$stmt->bind_param("ssi", $ip, $token, $uid);
|
||||
$stmt = $conn->prepare("UPDATE users SET latest_ip = ?, token = ? WHERE id = ?");
|
||||
$stmt->bind_param("ssi", $ip, $token, $id);
|
||||
$stmt->execute();
|
||||
|
||||
if ($currentHighScore > $user['highScore']) {
|
||||
$stmt = $conn->prepare("UPDATE users SET highScore = ? WHERE uid = ?");
|
||||
$stmt->bind_param("ii", $currentHighScore, $uid);
|
||||
$stmt = $conn->prepare("UPDATE users SET highScore = ? WHERE id = ?");
|
||||
$stmt->bind_param("ii", $currentHighScore, $id);
|
||||
$stmt->execute();
|
||||
$user['highScore'] = $currentHighScore;
|
||||
}
|
||||
@@ -47,7 +45,7 @@ $data = ["session" => $token];
|
||||
if ($loginType === "0") {
|
||||
$data += [
|
||||
"username" => $user['username'],
|
||||
"userid" => $uid,
|
||||
"id" => $id,
|
||||
"highscore" => (string)$user['highScore'],
|
||||
"icon" => (int)$user['icon'],
|
||||
"overlay" => (int)$user['overlay'],
|
||||
@@ -63,7 +61,7 @@ if ($loginType === "0") {
|
||||
} elseif ($loginType === "1") {
|
||||
$data += [
|
||||
"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"]));
|
||||
}
|
||||
|
||||
$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->execute();
|
||||
$res = $stmt->get_result();
|
||||
@@ -35,7 +35,7 @@ $token = bin2hex(random_bytes(256));
|
||||
$ip = getIPAddress();
|
||||
$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->execute();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user