chore: App-router-migration(/auth/verify) add missing metadata / page & extract components into /module (#16444)
* create StripeRepository and simplify code * verify-email-change: extract getServerSideProps * add verify-email-change to app router * auth/verify: Add metadata in app router * auth/verify: extract client component into /modules * fix type checks for stripe * fix stripe session handler * improve getServerSideProps for verify-email-change * add title to verify-email-change page metadata * add title to verify page metadata * refactor * add safety * fix * remove references to pages for verify-email --------- Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
12 files changed
+553
-459
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import type { GetServerSidePropsContext } from "next";
|
||||
import { z } from "zod";
|
||||
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
const tokenSchema = z.object({
|
||||
token: z.string(),
|
||||
});
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
const parsed = tokenSchema.safeParse(context.query);
|
||||
if (!parsed.success) {
|
||||
return {
|
||||
notFound: true,
|
||||
} as const;
|
||||
}
|
||||
const { token } = parsed.data;
|
||||
|
||||
if (!token) {
|
||||
return {
|
||||
notFound: true,
|
||||
} as const;
|
||||
}
|
||||
|
||||
const params = new URLSearchParams({
|
||||
token,
|
||||
});
|
||||
|
||||
const response = await fetch(`${WEBAPP_URL}/api/auth/verify-email?${params.toString()}`, {
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return {
|
||||
props: {
|
||||
updateSession: false,
|
||||
token,
|
||||
updatedEmail: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
return {
|
||||
props: {
|
||||
updateSession: true,
|
||||
token,
|
||||
updatedEmail: data.updatedEmail ?? null,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user