The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
chore: refactor
Catalin Pitb2cca9afb677
diff --git a/apps/web/src/app/(unauthenticated)/unverified-account/page.tsx b/apps/web/src/app/(unauthenticated)/unverified-account/page.tsxindex 5199249e0..dc98044ae 100644--- a/apps/web/src/app/(unauthenticated)/unverified-account/page.tsx+++ b/apps/web/src/app/(unauthenticated)/unverified-account/page.tsx@@ -18,7 +18,7 @@ export default function UnverifiedAccount() {const searchParams = useSearchParams();const { toast } = useToast();- const encryptedEmail = searchParams?.get('t') ?? ''; // TODO: choose a better name instead of t+ const encryptedEmail = searchParams?.get('token') ?? '';const { mutateAsync: sendConfirmationEmail } = trpc.profile.sendConfirmationEmail.useMutation();@@ -26,7 +26,7 @@ export default function UnverifiedAccount() {try {setIsButtonDisabled(true);- await sendConfirmationEmail({ email: encryptedEmail });+ await sendConfirmationEmail({ encryptedEmail });toast({title: 'Success',diff --git a/apps/web/src/components/forms/signin.tsx b/apps/web/src/components/forms/signin.tsxindex 4e3701c84..0353333cf 100644--- a/apps/web/src/components/forms/signin.tsx+++ b/apps/web/src/components/forms/signin.tsx@@ -134,7 +134,7 @@ export const SignInForm = ({ className, isGoogleSSOEnabled }: SignInFormProps) =if (result.error === ErrorCode.UNVERIFIED_EMAIL) {const encryptedEmail = await encryptSecondaryData({ data: email });- router.push(`/unverified-account?t=${encryptedEmail}`);+ router.push(`/unverified-account?token=${encryptedEmail}`);return;}diff --git a/apps/web/src/components/forms/signup.tsx b/apps/web/src/components/forms/signup.tsxindex 190084226..bc7ee0ce5 100644--- a/apps/web/src/components/forms/signup.tsx+++ b/apps/web/src/components/forms/signup.tsx@@ -70,7 +70,7 @@ export const SignUpForm = ({ className, isGoogleSSOEnabled }: SignUpFormProps) =const encryptedEmail = await encryptSecondaryData({ data: email });- router.push(`/unverified-account?t=${encryptedEmail}`);+ router.push(`/unverified-account?token=${encryptedEmail}`);toast({title: 'Registration Successful',diff --git a/packages/lib/server-only/user/send-confirmation-token.ts b/packages/lib/server-only/user/send-confirmation-token.tsindex 6c070125b..af4a97a48 100644--- a/packages/lib/server-only/user/send-confirmation-token.ts+++ b/packages/lib/server-only/user/send-confirmation-token.ts@@ -37,7 +37,6 @@ export const sendConfirmationToken = async ({ email }: { email: string }) => {throw new Error(`Failed to create the verification token`);}- // TODO: Revisit tomorrowtry {await sendConfirmationEmail({ userId: user.id });diff --git a/packages/trpc/server/profile-router/router.ts b/packages/trpc/server/profile-router/router.tsindex 510e2a6fd..44d0f59bd 100644--- a/packages/trpc/server/profile-router/router.ts+++ b/packages/trpc/server/profile-router/router.ts@@ -135,11 +135,15 @@ export const profileRouter = router({.input(ZConfirmEmailMutationSchema).mutation(async ({ input }) => {try {- const { email } = input;+ const { encryptedEmail } = input;++ const decryptedEmail = decryptSecondaryData(encryptedEmail);- const decryptedEmail = decryptSecondaryData(email);+ if (!decryptedEmail) {+ throw new Error('Email is required');+ }- return await sendConfirmationToken({ email: decryptedEmail ?? '' }); // TODO: fix this tomorrow+ return await sendConfirmationToken({ email: decryptedEmail });} catch (err) {let message = 'We were unable to send a confirmation email. Please try again.';diff --git a/packages/trpc/server/profile-router/schema.ts b/packages/trpc/server/profile-router/schema.tsindex 5aa9844ca..897a4912d 100644--- a/packages/trpc/server/profile-router/schema.ts+++ b/packages/trpc/server/profile-router/schema.ts@@ -30,9 +30,9 @@ export const ZResetPasswordFormSchema = z.object({password: z.string().min(6),token: z.string().min(1),});-// TODO: revisit this+export const ZConfirmEmailMutationSchema = z.object({- email: z.string().min(1),+ encryptedEmail: z.string().min(1),});export type TRetrieveUserByIdQuerySchema = z.infer<typeof ZRetrieveUserByIdQuerySchema>;