summary refs log tree commit diff
path: root/src/routes/auth/register.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/auth/register.ts')
-rw-r--r--src/routes/auth/register.ts19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/routes/auth/register.ts b/src/routes/auth/register.ts

index 49a3bd6c..f39206f2 100644 --- a/src/routes/auth/register.ts +++ b/src/routes/auth/register.ts
@@ -4,6 +4,8 @@ import bcrypt from "bcrypt"; import { check, Email, EMAIL_REGEX, FieldErrors, Length } from "../../util/instanceOf"; import "missing-native-js-functions"; import { generateToken } from "./login"; +import { getIpAdress, IPAnalysis, isProxy } from "../../util/ipAddress"; +import { HTTPError } from "lambert-server"; const router: Router = Router(); @@ -34,7 +36,19 @@ router.post( gift_code_sku_id, // ? what is this captcha_key } = req.body; - console.log("register", req.body.email, req.body.username, req.headers["cf-connecting-ip"]); + + // get register Config + const { register, security } = Config.get(); + const ip = getIpAdress(req); + + if (register.blockProxies) { + if (isProxy(await IPAnalysis(ip))) { + console.log(`proxy ${ip} blocked from registration`); + throw new HTTPError("Your IP is blocked from registration"); + } + } + + console.log("register", req.body.email, req.body.username, ip); // TODO: automatically join invite // TODO: gift_code_sku_id? // TODO: check password strength @@ -51,9 +65,6 @@ router.post( // discriminator will be randomly generated let discriminator = ""; - // get register Config - const { register, security } = Config.get(); - // check if registration is allowed if (!register.allowNewRegistration) { throw FieldErrors({