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
16 changes: 13 additions & 3 deletions apps/mail/app/(auth)/login/login-client.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { useEffect, type ReactNode, useState, Suspense } from 'react';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { Suspense, useEffect, useState, type ReactNode } from 'react';
import type { EnvVarInfo } from '@zero/server/auth-providers';
import ErrorMessage from '@/app/(auth)/login/error-message';
import { signIn, useSession } from '@/lib/auth-client';
import { Google, Microsoft } from '@/components/icons/icons';
import ErrorMessage from '@/app/(auth)/login/error-message';
import { Button } from '@/components/ui/button';
import { TriangleAlert } from 'lucide-react';
import { signIn } from '@/lib/auth-client';
import { useNavigate } from 'react-router';
import { useQueryState } from 'nuqs';
import { toast } from 'sonner';

interface EnvVarStatus {
Expand Down Expand Up @@ -68,6 +70,7 @@ const getProviderIcon = (providerId: string, className?: string): ReactNode => {
function LoginClientContent({ providers, isProd }: LoginClientProps) {
const navigate = useNavigate();
const [expandedProviders, setExpandedProviders] = useState<Record<string, boolean>>({});
const [error, _] = useQueryState('error');

useEffect(() => {
const missing = providers.find((p) => p.required && !p.enabled);
Expand Down Expand Up @@ -135,6 +138,13 @@ function LoginClientContent({ providers, isProd }: LoginClientProps) {
<div className="w-full space-y-4">
<p className="text-center text-4xl font-bold text-white md:text-5xl">Login to Zero</p>

{error && (
<Alert variant="default" className="border-orange-500/40 bg-orange-500/10">
<AlertTitle className="text-orange-400">Error</AlertTitle>
<AlertDescription>Failed to log you in. Please try again.</AlertDescription>
</Alert>
)}

{shouldShowDetailedConfig && (
<div className="rounded-lg border border-black/10 bg-black/5 p-5 dark:border-white/10 dark:bg-white/5">
<div className="flex flex-col space-y-4">
Expand Down
7 changes: 7 additions & 0 deletions apps/server/src/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ const createAuthConfig = () => {
trustedProviders: ['google', 'microsoft'],
},
},
onAPIError: {
onError: (error, ctx) => {
console.error('API Error', error);
},
errorURL: `${env.VITE_PUBLIC_APP_URL}/login`,
throw: true,
},
} satisfies BetterAuthOptions;
};

Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ packages:
- scripts/*
catalog:
zod: ^3.25.42
better-auth: ^1.2.8
better-auth: ^1.2.9
autumn-js: ^0.0.48
superjson: ^2.2.2
'@trpc/server': ^11.1.4
Expand Down