Andrew commited on
Commit
27d17a3
·
1 Parent(s): 911a9cb

(fix) Normalize whitelist credentials for password login

Browse files
src/routes/login/password/+server.ts CHANGED
@@ -33,8 +33,20 @@ const passwordWhitelist = z
33
  .array(
34
  z
35
  .object({
36
- username: z.string().optional(),
37
- email: z.string().email().optional(),
 
 
 
 
 
 
 
 
 
 
 
 
38
  passwordHash: z.string().length(64),
39
  name: z.string().optional(),
40
  isAdmin: z.boolean().optional(),
 
33
  .array(
34
  z
35
  .object({
36
+ username: z
37
+ .preprocess((val) => {
38
+ if (typeof val !== "string") return val;
39
+ const trimmed = val.trim();
40
+ return trimmed.length === 0 ? undefined : trimmed;
41
+ }, z.string().min(1))
42
+ .optional(),
43
+ email: z
44
+ .preprocess((val) => {
45
+ if (typeof val !== "string") return val;
46
+ const trimmed = val.trim();
47
+ return trimmed.length === 0 ? undefined : trimmed;
48
+ }, z.string().email())
49
+ .optional(),
50
  passwordHash: z.string().length(64),
51
  name: z.string().optional(),
52
  isAdmin: z.boolean().optional(),