fix: safe-parse query schema in signup page to avoid zod throw (#18927)
This commit is contained in:
@@ -49,9 +49,6 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
|
||||
emailVerificationEnabled,
|
||||
};
|
||||
|
||||
// username + email prepopulated from query params
|
||||
const { username: preFillusername, email: prefilEmail } = querySchema.parse(ctx.query);
|
||||
|
||||
if ((process.env.NEXT_PUBLIC_DISABLE_SIGNUP === "true" && !token) || signupDisabled) {
|
||||
return {
|
||||
redirect: {
|
||||
@@ -63,13 +60,15 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
|
||||
|
||||
// no token given, treat as a normal signup without verification token
|
||||
if (!token) {
|
||||
// username + email prepopulated from query params
|
||||
const queryData = querySchema.safeParse(ctx.query);
|
||||
return {
|
||||
props: JSON.parse(
|
||||
JSON.stringify({
|
||||
...props,
|
||||
prepopulateFormValues: {
|
||||
username: preFillusername || null,
|
||||
email: prefilEmail || null,
|
||||
username: queryData.success ? queryData.data.username : null,
|
||||
email: queryData.success ? queryData.data.email : null,
|
||||
},
|
||||
})
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user