mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-30 14:38:57 +02:00
Pr comments
This commit is contained in:
parent
027a19e827
commit
c39004a998
2 changed files with 20 additions and 43 deletions
|
@ -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,17 +154,7 @@ 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 {
|
||||
async jwt({ token }) {
|
||||
const userId = token.sub;
|
||||
const isGuest = userId?.startsWith("guest-");
|
||||
|
||||
|
@ -184,9 +166,6 @@ const {
|
|||
select: {
|
||||
name: true,
|
||||
email: true,
|
||||
timeFormat: true,
|
||||
timeZone: true,
|
||||
weekStart: true,
|
||||
image: true,
|
||||
},
|
||||
});
|
||||
|
@ -195,10 +174,6 @@ const {
|
|||
token.name = user.name;
|
||||
token.email = user.email;
|
||||
token.picture = user.image;
|
||||
token.timeFormat = user.timeFormat;
|
||||
token.timeZone = user.timeZone;
|
||||
token.weekStart = user.weekStart;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,6 +120,8 @@ export const auth = router({
|
|||
name,
|
||||
email,
|
||||
timeZone: input.timeZone,
|
||||
timeFormat: input.timeFormat,
|
||||
weekStart: input.weekStart,
|
||||
locale: input.locale,
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue