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}$/;
|
||||
|
||||
@@ -32,6 +33,21 @@ export async function addFirstMinecraftAccount(formData: FormData) {
|
||||
redirect("/welcome/minecraft?error=invalid-format");
|
||||
}
|
||||
|
||||
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(`/welcome/minecraft?error=${network.reason === "blocked" ? "vpn-blocked" : "ip-check-unavailable"}`);
|
||||
}
|
||||
|
||||
const profile = await lookupJavaProfile(requestedUsername);
|
||||
if (!profile && !confirmed) {
|
||||
redirect(`/welcome/minecraft?unverified=${encodeURIComponent(requestedUsername)}`);
|
||||
|
||||
@@ -5,6 +5,8 @@ import { addFirstMinecraftAccount } from "../actions";
|
||||
const errors: Record<string, string> = {
|
||||
"invalid-format": "Java usernames use 3–16 letters, numbers, or underscores.",
|
||||
"already-registered": "That Minecraft account is already registered.",
|
||||
"vpn-blocked": "Turn off your VPN, proxy, or Tor connection before adding a Minecraft account.",
|
||||
"ip-check-unavailable": "We could not verify your network. Try again without a VPN or contact an administrator.",
|
||||
};
|
||||
|
||||
export default async function MinecraftStepPage({
|
||||
|
||||
Reference in New Issue
Block a user