fix borked e2e
parent
de12a7a11a
commit
b70838bed3
|
@ -2,6 +2,7 @@ import { expect } from "@playwright/test";
|
|||
import { randomBytes } from "crypto";
|
||||
|
||||
import { IS_CALCOM } from "@calcom/lib/constants";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
|
||||
import { test } from "./lib/fixtures";
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ async function handler(req: RequestWithUsernameStatus, res: NextApiResponse) {
|
|||
if (token) {
|
||||
foundToken = await findTokenByToken({ token });
|
||||
throwIfTokenExpired(foundToken?.expires);
|
||||
validateUsernameForTeam({ username, email, teamId: foundToken?.teamId });
|
||||
validateUsernameForTeam({ username, email, teamId: foundToken?.teamId ?? null });
|
||||
} else {
|
||||
const usernameAndEmailValidation = await validateUsername(username, email);
|
||||
if (!usernameAndEmailValidation.isValid) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import dayjs from "@calcom/dayjs";
|
||||
import { HttpError } from "@calcom/lib/http-error";
|
||||
import { validateUsernameInTeam } from "@calcom/lib/validateUsername";
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
export async function findTokenByToken({ token }: { token: string }) {
|
||||
const foundToken = await prisma.verificationToken.findFirst({
|
||||
|
@ -24,7 +25,8 @@ export async function findTokenByToken({ token }: { token: string }) {
|
|||
return foundToken;
|
||||
}
|
||||
|
||||
export function throwIfTokenExpired(expires: Date) {
|
||||
export function throwIfTokenExpired(expires?: Date) {
|
||||
if (!expires) return;
|
||||
if (dayjs(expires).isBefore(dayjs())) {
|
||||
throw new HttpError({
|
||||
statusCode: 401,
|
||||
|
|
Loading…
Reference in New Issue