From 7cc2534f9183bb3116b19ffca52789f1f50900f7 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 6 May 2025 00:56:04 +0500 Subject: feat: account registration and login --- public/account/login/index.php | 80 +++++++++++++++++++++++++++++++++-------- public/account/login/twitch.php | 2 +- 2 files changed, 67 insertions(+), 15 deletions(-) (limited to 'public/account/login') diff --git a/public/account/login/index.php b/public/account/login/index.php index 4eb37ae..7c562d1 100644 --- a/public/account/login/index.php +++ b/public/account/login/index.php @@ -1,16 +1,44 @@ prepare("SELECT secret_key, password FROM users WHERE username = ? AND password IS NOT NULL"); + $stmt->execute([$username]); + + if ($row = $stmt->fetch()) { + if (password_verify($password, $row["password"])) { + setcookie("secret_key", $row["secret_key"], $remember ? (time() + ACCOUNT_COOKIE_MAX_LIFETIME) : 0, "/"); + header("Location: /account"); + exit; + } else { + generate_alert("/account/login", "Passwords do not match!", 403); + exit; + } + } else { + generate_alert("/account/login", "User not found or is not accessable", 404); + exit; + } +} ?> @@ -25,21 +53,45 @@ if (!ACCOUNT_REGISTRATION_ENABLE) {
- -
-
+
+ +
- -
- -
- +
+
+ + +
+
+ + +
+
+ + +
+
+ + + Register + +
+
+ + +
+ Login with Twitch +

Logging in via Twitch gives you the ability to use + emotes in your Twitch chat. +

+
+
diff --git a/public/account/login/twitch.php b/public/account/login/twitch.php index 05093cd..e3fe57a 100644 --- a/public/account/login/twitch.php +++ b/public/account/login/twitch.php @@ -129,7 +129,7 @@ if ($row = $stmt->fetch()) { $_SESSION["user_id"] = $user_id; $_SESSION["user_name"] = $user_name; -setcookie("secret_key", $user_secret_key, time() + 86400 * 30, "/"); +setcookie("secret_key", $user_secret_key, time() + ACCOUNT_COOKIE_MAX_LIFETIME, "/"); $db = null; -- cgit v1.2.3