diff --git a/apps/web/src/next-auth.ts b/apps/web/src/next-auth.ts index 63edb07ab..de91f082f 100644 --- a/apps/web/src/next-auth.ts +++ b/apps/web/src/next-auth.ts @@ -4,7 +4,6 @@ import { redirect } from "next/navigation"; import NextAuth from "next-auth"; import type { Provider } from "next-auth/providers"; import { cache } from "react"; -import z from "zod"; import { CustomPrismaAdapter } from "./auth/adapters/prisma"; import { isEmailBanned, isEmailBlocked } from "./auth/helpers/is-email-blocked"; @@ -17,13 +16,6 @@ import { OIDCProvider } from "./auth/providers/oidc"; import { RegistrationTokenProvider } from "./auth/providers/registration-token"; import { nextAuthConfig } from "./next-auth.config"; -const sessionUpdateSchema = z.object({ - locale: z.string().nullish(), - timeFormat: z.enum(["hours12", "hours24"]).nullish(), - timeZone: z.string().nullish(), - weekStart: z.number().nullish(), -}); - const { auth: originalAuth, handlers, @@ -162,43 +154,26 @@ const { return true; }, - async jwt({ token, session }) { - if (session) { - const parsed = sessionUpdateSchema.safeParse(session); - if (parsed.success) { - Object.entries(parsed.data).forEach(([key, value]) => { - token[key] = value; - }); - } else { - console.error(parsed.error); - } - } else { - const userId = token.sub; - const isGuest = userId?.startsWith("guest-"); + async jwt({ token }) { + const userId = token.sub; + const isGuest = userId?.startsWith("guest-"); - if (userId && !isGuest) { - const user = await prisma.user.findUnique({ - where: { - id: userId, - }, - select: { - name: true, - email: true, - timeFormat: true, - timeZone: true, - weekStart: true, - image: true, - }, - }); + if (userId && !isGuest) { + const user = await prisma.user.findUnique({ + where: { + id: userId, + }, + select: { + name: true, + email: true, + image: true, + }, + }); - if (user) { - token.name = user.name; - token.email = user.email; - token.picture = user.image; - token.timeFormat = user.timeFormat; - token.timeZone = user.timeZone; - token.weekStart = user.weekStart; - } + if (user) { + token.name = user.name; + token.email = user.email; + token.picture = user.image; } } diff --git a/apps/web/src/trpc/routers/auth.ts b/apps/web/src/trpc/routers/auth.ts index c7298e032..750e39216 100644 --- a/apps/web/src/trpc/routers/auth.ts +++ b/apps/web/src/trpc/routers/auth.ts @@ -120,6 +120,8 @@ export const auth = router({ name, email, timeZone: input.timeZone, + timeFormat: input.timeFormat, + weekStart: input.weekStart, locale: input.locale, }, });