mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-06 09:59:00 +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" />
|
<Trans i18nKey="email" />
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} />
|
<Input disabled={form.formState.isSubmitting} {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { auth } from "@/next-auth";
|
||||||
import { decryptToken } from "@/utils/session";
|
import { decryptToken } from "@/utils/session";
|
||||||
|
|
||||||
type EmailChangePayload = {
|
type EmailChangePayload = {
|
||||||
fromEmail: string;
|
userId: string;
|
||||||
toEmail: string;
|
toEmail: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ const handleEmailChange = async (token: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = await prisma.user.update({
|
const user = await prisma.user.update({
|
||||||
where: { email: payload.fromEmail },
|
where: { id: payload.userId },
|
||||||
data: { email: payload.toEmail },
|
data: { email: payload.toEmail },
|
||||||
select: {
|
select: {
|
||||||
customerId: true,
|
customerId: true,
|
||||||
|
|
|
@ -112,7 +112,7 @@ export const user = router({
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
const currentUser = await prisma.user.findUnique({
|
const currentUser = await prisma.user.findUnique({
|
||||||
where: { id: ctx.user.id },
|
where: { id: ctx.user.id },
|
||||||
select: { email: true },
|
select: { email: true, id: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!currentUser) {
|
if (!currentUser) {
|
||||||
|
@ -137,7 +137,7 @@ export const user = router({
|
||||||
// create a verification token
|
// create a verification token
|
||||||
const token = await createToken(
|
const token = await createToken(
|
||||||
{
|
{
|
||||||
fromEmail: currentUser.email,
|
userId: currentUser.id,
|
||||||
toEmail: input.email,
|
toEmail: input.email,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue