mirror of
https://github.com/4ev-link/4ev.link.git
synced 2026-01-14 08:38:39 +00:00
Revert: Update signin.js
This commit is contained in:
@@ -22,8 +22,7 @@ export async function onRequestPost({ request, env }) {
|
|||||||
body:JSON.stringify({ secret:env.TURNSTILE_KEY, response:token })
|
body:JSON.stringify({ secret:env.TURNSTILE_KEY, response:token })
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const captchaSuccess = (await vR.json()).success;
|
if (!(await vR.json()).success)
|
||||||
if (!captchaSuccess)
|
|
||||||
return new Response("CAPTCHA verification failed.",{ status:403 });
|
return new Response("CAPTCHA verification failed.",{ status:403 });
|
||||||
|
|
||||||
const { username, pass_hash } = body;
|
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 = ?")
|
.prepare("SELECT pass_hash, banned_until FROM users WHERE username = ?")
|
||||||
.bind(username)
|
.bind(username)
|
||||||
.first();
|
.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)
|
if (user?.pass_hash !== pass_hash)
|
||||||
return new Response("Invalid credentials",{ status:401 });
|
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 });
|
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 });
|
return Response.json({ success:true, username });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return new Response(e.message,{ status:500 });
|
return new Response(e.message,{ status:500 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user