fix: email update bug (#10306)

Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
Udit TakkarandKeith Williams authored and GitHub committed 2023-07-27 10:41:33 +02:00
1 parent cdb78b686b
commit 4f488be654
5 files changed
+24 -4

No files matched your search

@@ -350,6 +350,14 @@ export const AUTH_OPTIONS: AuthOptions = {
providers,
callbacks: {
async jwt({ token, user, account, trigger, session }) {
if (trigger === "update") {
return {
...token,
name: session?.name ?? token.name,
username: session?.username ?? token.username,
email: session?.email ?? token.email,
};
}
const autoMergeIdentities = async () => {
const existingUser = await prisma.user.findFirst({
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -98,6 +98,11 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
});
}
}
const hasEmailBeenChanged = userToUpdate.email !== data.email;
if (hasEmailBeenChanged) {
data.emailVerified = null;
}
const updatedUser = await prisma.user.update({
where: {