feat(network): add ProxyCheck IP intelligence
This commit is contained in:
@@ -7,6 +7,7 @@ import { redirect } from "next/navigation";
|
||||
import { recordUserEvent } from "@/lib/audit";
|
||||
import { db } from "@/lib/database";
|
||||
import { requireCurrentUser } from "@/lib/auth/user-session";
|
||||
import { checkAccountAdditionNetwork, toAuditIpData } from "@/lib/ip-intelligence";
|
||||
|
||||
const USERNAME_PATTERN = /^[A-Za-z0-9_]{3,16}$/;
|
||||
|
||||
@@ -27,6 +28,21 @@ export async function addMinecraftAccount(formData: FormData) {
|
||||
const confirmed = formData.get("confirmUnverified") === "yes";
|
||||
if (!USERNAME_PATTERN.test(requestedUsername)) redirect("/account?error=invalid-username");
|
||||
|
||||
const network = await checkAccountAdditionNetwork();
|
||||
if (!network.allowed) {
|
||||
await recordUserEvent(
|
||||
user,
|
||||
network.reason === "blocked"
|
||||
? "games.minecraft.account-manager.network.vpn-blocked"
|
||||
: "games.minecraft.account-manager.network.classification-unavailable",
|
||||
{
|
||||
attemptedUsername: requestedUsername,
|
||||
ipIntelligence: network.intelligence ? toAuditIpData(network.intelligence) : null,
|
||||
},
|
||||
);
|
||||
redirect(`/account?error=${network.reason === "blocked" ? "vpn-blocked" : "ip-check-unavailable"}`);
|
||||
}
|
||||
|
||||
const profile = await lookupJavaProfile(requestedUsername);
|
||||
if (!profile && !confirmed) redirect(`/account?unverified=${encodeURIComponent(requestedUsername)}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user