Spaces:
Running
Running
Commit
•
002a2a0
1
Parent(s):
aa125df
🩹 Make preferred_username optional
Browse files
src/routes/login/callback/updateUser.ts
CHANGED
@@ -20,12 +20,15 @@ export async function updateUser(params: {
|
|
20 |
sub: hfUserId,
|
21 |
} = z
|
22 |
.object({
|
23 |
-
preferred_username: z.string(),
|
24 |
name: z.string(),
|
25 |
picture: z.string(),
|
26 |
sub: z.string(),
|
27 |
email: z.string().email().optional(),
|
28 |
})
|
|
|
|
|
|
|
29 |
.parse(userData);
|
30 |
|
31 |
const existingUser = await collections.users.findOne({ hfUserId });
|
|
|
20 |
sub: hfUserId,
|
21 |
} = z
|
22 |
.object({
|
23 |
+
preferred_username: z.string().optional(),
|
24 |
name: z.string(),
|
25 |
picture: z.string(),
|
26 |
sub: z.string(),
|
27 |
email: z.string().email().optional(),
|
28 |
})
|
29 |
+
.refine((data) => data.preferred_username || data.email, {
|
30 |
+
message: "Either preferred_username or email must be provided by the provider.",
|
31 |
+
})
|
32 |
.parse(userData);
|
33 |
|
34 |
const existingUser = await collections.users.findOne({ hfUserId });
|