summary refs log tree commit diff
path: root/src/api/routes/auth
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/auth')
-rw-r--r--src/api/routes/auth/login.ts11
-rw-r--r--src/api/routes/auth/mfa/totp.ts9
-rw-r--r--src/api/routes/auth/register.ts31
-rw-r--r--src/api/routes/auth/verify/view-backup-codes-challenge.ts6
4 files changed, 4 insertions, 53 deletions
diff --git a/src/api/routes/auth/login.ts b/src/api/routes/auth/login.ts

index bcaccb30..9bed5aab 100644 --- a/src/api/routes/auth/login.ts +++ b/src/api/routes/auth/login.ts
@@ -1,21 +1,12 @@ import { Request, Response, Router } from "express"; import { route, getIpAdress, verifyCaptcha } from "@fosscord/api"; import bcrypt from "bcrypt"; -import { Config, User, generateToken, adjustEmail, FieldErrors } from "@fosscord/util"; +import { Config, User, generateToken, adjustEmail, FieldErrors, LoginSchema } from "@fosscord/util"; import crypto from "crypto"; const router: Router = Router(); export default router; -export interface LoginSchema { - login: string; - password: string; - undelete?: boolean; - captcha_key?: string; - login_source?: string; - gift_code_sku_id?: string; -} - router.post("/", route({ body: "LoginSchema" }), async (req: Request, res: Response) => { const { login, password, captcha_key, undelete } = req.body as LoginSchema; const email = adjustEmail(login); diff --git a/src/api/routes/auth/mfa/totp.ts b/src/api/routes/auth/mfa/totp.ts
index 50b9e9c8..96a48b66 100644 --- a/src/api/routes/auth/mfa/totp.ts +++ b/src/api/routes/auth/mfa/totp.ts
@@ -1,17 +1,10 @@ import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; -import { BackupCode, FieldErrors, generateToken, User } from "@fosscord/util"; +import { BackupCode, generateToken, User, TotpSchema } from "@fosscord/util"; import { verifyToken } from "node-2fa"; import { HTTPError } from "lambert-server"; const router = Router(); -export interface TotpSchema { - code: string, - ticket: string, - gift_code_sku_id?: string | null, - login_source?: string | null, -} - router.post("/", route({ body: "TotpSchema" }), async (req: Request, res: Response) => { const { code, ticket, gift_code_sku_id, login_source } = req.body as TotpSchema; diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts
index b7122dad..84f8f838 100644 --- a/src/api/routes/auth/register.ts +++ b/src/api/routes/auth/register.ts
@@ -1,40 +1,11 @@ import { Request, Response, Router } from "express"; -import { Config, generateToken, Invite, FieldErrors, User, adjustEmail } from "@fosscord/util"; +import { Config, generateToken, Invite, FieldErrors, User, adjustEmail, RegisterSchema } from "@fosscord/util"; import { route, getIpAdress, IPAnalysis, isProxy, verifyCaptcha } from "@fosscord/api"; -import "missing-native-js-functions"; import bcrypt from "bcrypt"; import { HTTPError } from "lambert-server"; const router: Router = Router(); -export interface RegisterSchema { - /** - * @minLength 2 - * @maxLength 32 - */ - username: string; - /** - * @minLength 1 - * @maxLength 72 - */ - password?: string; - consent: boolean; - /** - * @TJS-format email - */ - email?: string; - fingerprint?: string; - invite?: string; - /** - * @TJS-type string - */ - date_of_birth?: Date; // "2000-04-03" - gift_code_sku_id?: string; - captcha_key?: string; - - promotional_email_opt_in?: boolean; -} - router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Response) => { const body = req.body as RegisterSchema; const { register, security } = Config.get(); diff --git a/src/api/routes/auth/verify/view-backup-codes-challenge.ts b/src/api/routes/auth/verify/view-backup-codes-challenge.ts
index 36bfeb0c..24de8ec5 100644 --- a/src/api/routes/auth/verify/view-backup-codes-challenge.ts +++ b/src/api/routes/auth/verify/view-backup-codes-challenge.ts
@@ -1,13 +1,9 @@ import { Router, Request, Response } from "express"; import { route } from "@fosscord/api"; -import { FieldErrors, User } from "@fosscord/util"; +import { FieldErrors, User, BackupCodesChallengeSchema } from "@fosscord/util"; import bcrypt from "bcrypt"; const router = Router(); -export interface BackupCodesChallengeSchema { - password: string; -} - router.post("/", route({ body: "BackupCodesChallengeSchema" }), async (req: Request, res: Response) => { const { password } = req.body as BackupCodesChallengeSchema;