From e910c71182afd78c1cb87c01d25ec40f313829f5 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Fri, 11 Mar 2022 19:57:19 +0100 Subject: [PATCH] fix: update verificationRequest -> verificationToken in several files --- apps/web/pages/api/teams/[team]/invite.ts | 2 +- apps/web/pages/auth/signup.tsx | 16 ++++++++-------- apps/web/playwright/auth/auth-index.test.ts | 4 ++-- apps/web/server/routers/viewer/teams.tsx | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/web/pages/api/teams/[team]/invite.ts b/apps/web/pages/api/teams/[team]/invite.ts index f37a5f79d6..1dc8ab4fe1 100644 --- a/apps/web/pages/api/teams/[team]/invite.ts +++ b/apps/web/pages/api/teams/[team]/invite.ts @@ -76,7 +76,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const token: string = randomBytes(32).toString("hex"); - await prisma.verificationRequest.create({ + await prisma.verificationToken.create({ data: { identifier: usernameOrEmail, token, diff --git a/apps/web/pages/auth/signup.tsx b/apps/web/pages/auth/signup.tsx index 28ff2e6412..1797b7bafd 100644 --- a/apps/web/pages/auth/signup.tsx +++ b/apps/web/pages/auth/signup.tsx @@ -100,14 +100,14 @@ export default function Signup({ email }: Props) { /> value === methods.watch("password") || (t("error_password_mismatch") as string), })} - className="mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-black focus:outline-none focus:ring-black sm:text-sm" + className="focus:outline-none mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-black focus:ring-black sm:text-sm" />
@@ -152,14 +152,14 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { notFound: true, }; } - const verificationRequest = await prisma.verificationRequest.findUnique({ + const verificationToken = await prisma.verificationToken.findUnique({ where: { token, }, }); - // for now, disable if no verificationRequestToken given or token expired - if (!verificationRequest || verificationRequest.expires < new Date()) { + // for now, disable if no verificationTokenToken given or token expired + if (!verificationToken || verificationToken.expires < new Date()) { return { notFound: true, }; @@ -169,7 +169,7 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { where: { AND: [ { - email: verificationRequest.identifier, + email: verificationToken.identifier, }, { emailVerified: { @@ -193,7 +193,7 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => { props: { isGoogleLoginEnabled: IS_GOOGLE_LOGIN_ENABLED, isSAMLLoginEnabled, - email: verificationRequest.identifier, + email: verificationToken.identifier, trpcState: ssr.dehydrate(), }, }; diff --git a/apps/web/playwright/auth/auth-index.test.ts b/apps/web/playwright/auth/auth-index.test.ts index 6bcb61aac6..c6f12d9e1f 100644 --- a/apps/web/playwright/auth/auth-index.test.ts +++ b/apps/web/playwright/auth/auth-index.test.ts @@ -35,7 +35,7 @@ test.describe("Can signup from a team invite", async () => { // Wait for the invite to be sent await page.waitForSelector(`[data-testid="member-email"][data-email="${testUser.email}"]`); - const tokenObj = await prisma.verificationRequest.findFirst({ + const tokenObj = await prisma.verificationToken.findFirst({ where: { identifier: testUser.email }, select: { token: true }, }); @@ -49,7 +49,7 @@ test.describe("Can signup from a team invite", async () => { where: { email: testUser.email }, }); // Delete verification request - await prisma.verificationRequest.delete({ + await prisma.verificationToken.delete({ where: { token }, }); }); diff --git a/apps/web/server/routers/viewer/teams.tsx b/apps/web/server/routers/viewer/teams.tsx index f9d0c9f260..819c638004 100644 --- a/apps/web/server/routers/viewer/teams.tsx +++ b/apps/web/server/routers/viewer/teams.tsx @@ -245,7 +245,7 @@ export const viewerTeamsRouter = createProtectedRouter() const token: string = randomBytes(32).toString("hex"); - await ctx.prisma.verificationRequest.create({ + await ctx.prisma.verificationToken.create({ data: { identifier: input.usernameOrEmail, token,