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

This commit is contained in:
Luke Vella 2025-04-14 15:48:51 +01:00 committed by GitHub
parent 72ca1d4c38
commit 96f0268567
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 5 deletions

View file

@ -117,7 +117,7 @@ export const ProfileEmailAddress = () => {
<Trans i18nKey="email" />
</FormLabel>
<FormControl>
<Input {...field} />
<Input disabled={form.formState.isSubmitting} {...field} />
</FormControl>
<FormMessage />
</FormItem>

View file

@ -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,

View file

@ -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,
},
{