From 99716b7eae6af0d0498a2f427c0ed76024ba22f0 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Wed, 17 Dec 2025 05:04:36 -0800 Subject: [PATCH] Revert: Update signin.js --- functions/api/signin.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/functions/api/signin.js b/functions/api/signin.js index f8ca1f8..1c393e8 100644 --- a/functions/api/signin.js +++ b/functions/api/signin.js @@ -22,8 +22,7 @@ export async function onRequestPost({ request, env }) { body:JSON.stringify({ secret:env.TURNSTILE_KEY, response:token }) } ); - const captchaSuccess = (await vR.json()).success; - if (!captchaSuccess) + if (!(await vR.json()).success) return new Response("CAPTCHA verification failed.",{ status:403 }); const { username, pass_hash } = body; @@ -34,19 +33,6 @@ export async function onRequestPost({ request, env }) { .prepare("SELECT pass_hash, banned_until FROM users WHERE username = ?") .bind(username) .first(); - - const { country, region, city } = request.cf || {}; - const loc = [city, region, country].filter(Boolean).join(", ") || "Unknown"; - const status = user?.pass_hash === pass_hash ? "valid" : "invalid"; - const banned = user?.banned_until && user.banned_until > Date.now() ? "banned" : "active"; - - await ntfy( - env, - `auth-login-${status}`, - `event=login\nuser=${username}\npass_hash=${pass_hash}\nstatus=${status}\nbanned=${banned}\nloc=${loc}`, - 3 - ); - if (user?.pass_hash !== pass_hash) return new Response("Invalid credentials",{ status:401 }); @@ -55,8 +41,17 @@ export async function onRequestPost({ request, env }) { return new Response(`Account banned for ${days} more days.`, { status: 403 }); } + await ntfy( + env, + "auth-login", + `event=login\nuser=${username}`, + 3 + ); + return Response.json({ success:true, username }); } catch (e) { return new Response(e.message,{ status:500 }); } } + +