Merge branch 'main' into feat/math-rendering

This commit is contained in:
viper151
2025-11-05 23:02:01 +01:00
committed by GitHub
6 changed files with 84 additions and 10 deletions

View File

@@ -26,6 +26,12 @@ const LoadingScreen = () => (
const ProtectedRoute = ({ children }) => {
const { user, isLoading, needsSetup } = useAuth();
// Platform mode: skip all auth UI and directly render children
if (import.meta.env.VITE_IS_PLATFORM === 'true') {
return children;
}
// Normal OSS mode: standard auth flow
if (isLoading) {
return <LoadingScreen />;
}

View File

@@ -29,31 +29,38 @@ export const AuthProvider = ({ children }) => {
// Check authentication status on mount
useEffect(() => {
// Platform mode: skip all auth checks, set dummy user
if (import.meta.env.VITE_IS_PLATFORM === 'true') {
setUser({ username: 'platform-user' });
setNeedsSetup(false);
setIsLoading(false);
return;
}
// Normal OSS mode: check auth status
checkAuthStatus();
}, []);
const checkAuthStatus = async () => {
try {
console.log('[AuthContext] Checking auth status...');
setIsLoading(true);
setError(null);
// Check if system needs setup
const statusResponse = await api.auth.status();
const statusData = await statusResponse.json();
console.log('[AuthContext] Status response:', statusData);
if (statusData.needsSetup) {
setNeedsSetup(true);
setIsLoading(false);
return;
}
// If we have a token, verify it
if (token) {
try {
const userResponse = await api.auth.user();
if (userResponse.ok) {
const userData = await userResponse.json();
setUser(userData.user);
@@ -75,7 +82,6 @@ export const AuthProvider = ({ children }) => {
console.error('[AuthContext] Auth status check failed:', error);
setError('Failed to check authentication status');
} finally {
console.log('[AuthContext] Auth check complete, isLoading=false');
setIsLoading(false);
}
};