mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-02 07:58:57 +02:00
🐛 Use user id to update email address (#1664)
This commit is contained in:
parent
72ca1d4c38
commit
96f0268567
3 changed files with 5 additions and 5 deletions
|
@ -117,7 +117,7 @@ export const ProfileEmailAddress = () => {
|
|||
<Trans i18nKey="email" />
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
<Input disabled={form.formState.isSubmitting} {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue