Skip to content

The Open Source DocuSign Alternative.

chore: encrypt and decrypt email addr

Catalin Pit311c8da8fc8a
diff --git a/apps/web/src/app/(unauthenticated)/unverified-account/page.tsx b/apps/web/src/app/(unauthenticated)/unverified-account/page.tsx
index 456971a9f..5199249e0 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 token = searchParams?.get('t') ?? '';
+ const encryptedEmail = searchParams?.get('t') ?? ''; // TODO: choose a better name instead of t
const { mutateAsync: sendConfirmationEmail } = trpc.profile.sendConfirmationEmail.useMutation();
@@ -26,9 +26,7 @@ export default function UnverifiedAccount() {
try {
setIsButtonDisabled(true);
- // TODO: decrypt email and send it
-
- await sendConfirmationEmail({ email: token ?? '' });
+ await sendConfirmationEmail({ email: encryptedEmail });
toast({
title: 'Success',
diff --git a/packages/trpc/server/profile-router/router.ts b/packages/trpc/server/profile-router/router.ts
index 09ee0351f..510e2a6fd 100644
--- a/packages/trpc/server/profile-router/router.ts
+++ b/packages/trpc/server/profile-router/router.ts
@@ -1,5 +1,6 @@
import { TRPCError } from '@trpc/server';
+import { decryptSecondaryData } from '@documenso/lib/server-only/crypto/decrypt';
import { forgotPassword } from '@documenso/lib/server-only/user/forgot-password';
import { getUserByEmail } from '@documenso/lib/server-only/user/get-user-by-email';
import { getUserById } from '@documenso/lib/server-only/user/get-user-by-id';
@@ -136,7 +137,9 @@ export const profileRouter = router({
try {
const { email } = input;
- return await sendConfirmationToken({ email });
+ const decryptedEmail = decryptSecondaryData(email);
+
+ return await sendConfirmationToken({ email: decryptedEmail ?? '' }); // TODO: fix this tomorrow
} 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.ts
index 671756e94..5aa9844ca 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().email().min(1),
+ email: z.string().min(1),
});
export type TRetrieveUserByIdQuerySchema = z.infer<typeof ZRetrieveUserByIdQuerySchema>;