Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/web/modules/auth/login-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ export default function Login({
<div className="w-full rounded-xl border border-subtle bg-default p-10 shadow-sm">
{/* Logo */}
<div className="mb-2 text-center">
<h1 className="font-cal text-xl font-bold text-emphasis">Cal.diy</h1>
<h1 className="font-cal text-xl font-bold text-emphasis">
{process.env.NEXT_PUBLIC_APP_NAME || "Crove"}
</h1>
</div>

{/* Heading */}
Expand Down
2 changes: 2 additions & 0 deletions packages/features/auth/lib/next-auth-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export const getProviders = (): Provider[] => {
profile(profile: {
sub: string;
email?: string;
email_verified?: boolean;
name?: string;
picture?: string;
avatar_url?: string;
Expand All @@ -350,6 +351,7 @@ export const getProviders = (): Provider[] => {
id: profile.sub,
name: profile.name || profile.email?.split("@")[0] || "User",
email: profile.email,
emailVerified: profile.email_verified ?? true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Critical Type Mismatch Bug

In the Prisma schema, the emailVerified field on the User model is defined as a DateTime? (timestamp), which maps to a Date | null type in TypeScript:

model User {
  ...
  emailVerified       DateTime?
}

By setting emailVerified: profile.email_verified ?? true, you are passing a boolean (true or false) to this field. When NextAuth attempts to create or update the user in the database via the Prisma adapter, Prisma will throw a validation/runtime error because it cannot write a boolean value to a DateTime column. This will completely break the OIDC login flow for new users.

To fix this, you should map the boolean verification status to a Date object (e.g., new Date()) if verified, or null if not verified.

Suggested change
emailVerified: profile.email_verified ?? true,
emailVerified: (profile.email_verified ?? true) ? new Date() : null,

image: profile.picture || profile.avatar_url || null,
organizations: profile.organizations,
} as unknown as User;
Expand Down
Loading