Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Use user id to update email address (#1664)

Luke Vella96f026856799
diff --git a/apps/web/src/app/[locale]/(admin)/settings/profile/profile-email-address.tsx b/apps/web/src/app/[locale]/(admin)/settings/profile/profile-email-address.tsx
index 804e0cb0f..7872f94a9 100644
--- a/apps/web/src/app/[locale]/(admin)/settings/profile/profile-email-address.tsx
+++ b/apps/web/src/app/[locale]/(admin)/settings/profile/profile-email-address.tsx
@@ -117,7 +117,7 @@ export const ProfileEmailAddress = () => {
<Trans i18nKey="email" />
</FormLabel>
<FormControl>
- <Input {...field} />
+ <Input disabled={form.formState.isSubmitting} {...field} />
</FormControl>
<FormMessage />
</FormItem>
diff --git a/apps/web/src/app/api/user/verify-email-change/route.ts b/apps/web/src/app/api/user/verify-email-change/route.ts
index 9ed194f63..0aa619ae5 100644
--- a/apps/web/src/app/api/user/verify-email-change/route.ts
+++ b/apps/web/src/app/api/user/verify-email-change/route.ts
@@ -9,7 +9,7 @@ import { auth } from "@/next-auth";
import { decryptToken } from "@/utils/session";
type EmailChangePayload = {
- fromEmail: string;
+ userId: string;
toEmail: string;
};
@@ -36,7 +36,7 @@ const handleEmailChange = async (token: string) => {
}
const user = await prisma.user.update({
- where: { email: payload.fromEmail },
+ where: { id: payload.userId },
data: { email: payload.toEmail },
select: {
customerId: true,
diff --git a/apps/web/src/trpc/routers/user.ts b/apps/web/src/trpc/routers/user.ts
index 9d8bfdade..acaff8774 100644
--- a/apps/web/src/trpc/routers/user.ts
+++ b/apps/web/src/trpc/routers/user.ts
@@ -112,7 +112,7 @@ export const user = router({
.mutation(async ({ input, ctx }) => {
const currentUser = await prisma.user.findUnique({
where: { id: ctx.user.id },
- select: { email: true },
+ select: { email: true, id: true },
});
if (!currentUser) {
@@ -137,7 +137,7 @@ export const user = router({
// create a verification token
const token = await createToken(
{
- fromEmail: currentUser.email,
+ userId: currentUser.id,
toEmail: input.email,
},
{