From a3b745358bbf0556832dfaf0d3f09a3f3f170675 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Thu, 21 Nov 2024 09:23:25 +0100 Subject: [PATCH] fix(api): :bug: Automatically make all usernames lowercase --- api/api/v1/accounts/id/index.ts | 2 +- api/api/v1/accounts/index.ts | 2 +- api/api/v1/accounts/update_credentials/index.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/api/api/v1/accounts/id/index.ts b/api/api/v1/accounts/id/index.ts index 2aea6198..b35a0fd2 100644 --- a/api/api/v1/accounts/id/index.ts +++ b/api/api/v1/accounts/id/index.ts @@ -23,7 +23,7 @@ export const meta = applyConfig({ export const schemas = { query: z.object({ - username: z.string().min(1).max(512), + username: z.string().min(1).max(512).toLowerCase(), }), }; diff --git a/api/api/v1/accounts/index.ts b/api/api/v1/accounts/index.ts index 50fe9e59..fea0734a 100644 --- a/api/api/v1/accounts/index.ts +++ b/api/api/v1/accounts/index.ts @@ -25,7 +25,7 @@ export const meta = applyConfig({ export const schemas = { json: z.object({ - username: z.string(), + username: z.string().toLowerCase(), email: z.string().toLowerCase(), password: z.string().optional(), agreement: z diff --git a/api/api/v1/accounts/update_credentials/index.ts b/api/api/v1/accounts/update_credentials/index.ts index 6481700c..8e7d3af9 100644 --- a/api/api/v1/accounts/update_credentials/index.ts +++ b/api/api/v1/accounts/update_credentials/index.ts @@ -46,6 +46,7 @@ export const schemas = { .min(3) .trim() .max(config.validation.max_username_size) + .toLowerCase() .refine( (s) => !config.filters.username.some((filter) => s.match(filter)),