summaryrefslogtreecommitdiff
path: root/public/account
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-05-03 16:50:50 +0500
committerilotterytea <iltsu@alright.party>2025-05-03 16:50:50 +0500
commit2c51a000a9f2f51f54b761e4975086f9db3780a4 (patch)
tree6fbe2871a652cf3264cfd42fede1d6369cefca84 /public/account
parenta196b0bdf3d7dd4a86c4bf0bc5d5065ac03cd268 (diff)
upd: big changes in database.sql + .webp is now default image format
Diffstat (limited to 'public/account')
-rw-r--r--public/account/delete.php10
-rw-r--r--public/account/login/twitch.php16
2 files changed, 9 insertions, 17 deletions
diff --git a/public/account/delete.php b/public/account/delete.php
index ecfcc80..4459edb 100644
--- a/public/account/delete.php
+++ b/public/account/delete.php
@@ -12,15 +12,7 @@ if (!isset($_SESSION["user_id"])) {
$id = $_SESSION["user_id"];
$db = new PDO(DB_URL, DB_USER, DB_PASS);
-
-$stmt = $db->prepare("UPDATE emotes SET uploaded_by = NULL WHERE uploaded_by = ?");
-$stmt->execute([$id]);
-
-$stmt = $db->prepare("DELETE FROM connections WHERE user_id = ?");
-$stmt->execute([$id]);
-
-$stmt = $db->prepare("DELETE FROM users WHERE id = ?");
-$stmt->execute([$id]);
+$db->prepare("DELETE FROM users WHERE id = ?")->execute([$id]);
session_unset();
session_destroy();
diff --git a/public/account/login/twitch.php b/public/account/login/twitch.php
index dfd319f..f322f42 100644
--- a/public/account/login/twitch.php
+++ b/public/account/login/twitch.php
@@ -69,9 +69,9 @@ if (empty($twitch_user["data"])) {
$twitch_user = $twitch_user["data"][0];
// saving it
-$_SESSION["twitch_access_token"] = $response["access_token"];
-$_SESSION["twitch_refresh_token"] = $response["refresh_token"];
-$_SESSION["twitch_expires_on"] = time() + intval($response["expires_in"]);
+$twitch_access_token = $response["access_token"];
+$twitch_refresh_token = $response["refresh_token"];
+$twitch_expires_on = time() + intval($response["expires_in"]);
$db = new PDO(DB_URL, DB_USER, DB_PASS);
@@ -102,21 +102,21 @@ if ($row = $stmt->fetch()) {
} else {
$user_secret_key = generate_random_string(32);
$user_name = $twitch_user["login"];
+ $user_id = bin2hex(random_bytes(16));
- $stmt = $db->prepare("INSERT INTO users(username, secret_key) VALUES (?, ?)");
- if (!$stmt->execute([$user_name, $user_secret_key])) {
+
+ $stmt = $db->prepare("INSERT INTO users(id, username, secret_key) VALUES (?, ?, ?)");
+ if (!$stmt->execute([$user_id, $user_name, $user_secret_key])) {
$db = null;
echo "Failed to create a user";
exit;
}
- $user_id = $db->lastInsertId();
-
$stmt = $db->prepare("INSERT INTO connections(user_id, alias_id, platform, data) VALUES (?, ?, 'twitch', ?)");
$stmt->execute([
$user_id,
$twitch_user["id"],
- $_SESSION["twitch_access_token"] . ":" . $_SESSION["twitch_refresh_token"] . ":" . $_SESSION["twitch_expires_on"]
+ sprintf("%s:%s:%s", $twitch_access_token, $twitch_refresh_token, $twitch_expires_on)
]);
}