Skip to content

Commit db07b31

Browse files
committed
Revert "fix: avoid blank screen during auth loading"
This reverts commit cfbac62.
1 parent ae12743 commit db07b31

2 files changed

Lines changed: 8 additions & 26 deletions

File tree

‎src/components/auth/RequireAuth.tsx‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import { Navigate, useLocation } from 'react-router-dom';
22
import { useAuth } from '@/lib/supabase/AuthProvider';
3-
import { Loader2 } from 'lucide-react';
43

54
export function RequireAuth({ children }: { children: React.ReactNode }) {
65
const { user, loading } = useAuth();
76
const location = useLocation();
87

9-
if (loading) {
10-
// Avoid a "blank screen" while Supabase loads/recovers the session.
11-
return (
12-
<div className="min-h-screen flex items-center justify-center bg-background">
13-
<Loader2 className="h-8 w-8 animate-spin text-primary" />
14-
</div>
15-
);
16-
}
8+
if (loading) return null;
179

1810
if (!user) {
1911
return <Navigate to="/login" state={{ from: location }} replace />;

‎src/lib/supabase/AuthProvider.tsx‎

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,13 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
2727
let mounted = true;
2828

2929
const init = async () => {
30-
try {
31-
const { data, error } = await supabase.auth.getSession();
32-
if (!mounted) return;
33-
if (error) console.warn('[Auth] getSession error:', error.message);
34-
setSession(data.session ?? null);
35-
if (data.session) {
36-
void hydrateSessionStore();
37-
void hydrateSettingsStore();
38-
}
39-
} catch (err) {
40-
// If local storage is corrupted (common), getSession can throw and we
41-
// end up stuck in a blank screen. Fail open to the login route.
42-
console.error('[Auth] getSession failed:', err);
43-
if (!mounted) return;
44-
setSession(null);
45-
} finally {
46-
if (mounted) setLoading(false);
30+
const { data } = await supabase.auth.getSession();
31+
if (!mounted) return;
32+
setSession(data.session ?? null);
33+
setLoading(false);
34+
if (data.session) {
35+
void hydrateSessionStore();
36+
void hydrateSettingsStore();
4737
}
4838
};
4939

0 commit comments

Comments
 (0)