Skip to content

Commit

Permalink
fix: use lowercase email for GSI (#1461)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianpoy authored Oct 18, 2024
2 parents 752780d + c050d70 commit 54fe5f4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/trpc/src/procedures/users/signInWithGoogle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const signInWithGoogle = publicProcedure
audience: input.clientId,
});
const payload = ticket.getPayload();
if (!payload?.email) {
const email = payload?.email;
if (!email) {
throw new TRPCError({
message: "Invalid clientId or credential",
code: "BAD_REQUEST",
Expand All @@ -39,11 +40,11 @@ export const signInWithGoogle = publicProcedure

const user = await prisma.user.upsert({
where: {
email: payload.email,
email: email.toLowerCase(),
},
create: {
name: payload.email.split("@")[0],
email: payload.email,
name: email.split("@")[0],
email: email.toLowerCase(),
},
update: {
lastLogin: new Date(),
Expand Down

0 comments on commit 54fe5f4

Please sign in to comment.