···1313 const queryParams = new URLSearchParams(location.search);
1414 const returnUrl = queryParams.get('returnUrl') || '/verifier';
15151616- console.log('Login component loaded with returnUrl =', returnUrl);
1616+ console.log('Login component: returnUrl =', returnUrl);
1717+1818+ // Log auth status to debug
1919+ useEffect(() => {
2020+ console.log('Login component auth status:', {
2121+ isAuthenticated,
2222+ loading,
2323+ hasError: !!error,
2424+ returnUrl
2525+ });
2626+ }, [isAuthenticated, loading, error, returnUrl]);
17271828 // Handle redirection after successful authentication
1929 useEffect(() => {
2030 if (isAuthenticated) {
2121- console.log('Login page: User is authenticated, redirecting to:', returnUrl);
3131+ console.log('Login: User is authenticated, redirecting to', returnUrl);
22322323- // First try React Router navigation
2424- navigate(returnUrl, { replace: true });
2525-2626- // As a backup, also use direct redirection after a short delay
3333+ // Set a short delay to ensure state updates complete
2734 setTimeout(() => {
2828- if (window.location.pathname !== returnUrl.split('?')[0]) {
2929- console.log('Login page: Using fallback redirect to:', returnUrl);
3030- window.location.href = returnUrl;
3131- }
3232- }, 200);
3535+ console.log('Login: Executing redirect to', returnUrl);
3636+ window.location.replace(returnUrl);
3737+ }, 100);
3338 }
3434- }, [isAuthenticated, navigate, returnUrl]);
3939+ }, [isAuthenticated, returnUrl]);
35403641 const handleInputChange = (event) => {
3742 setHandle(event.target.value);
+14-14
src/components/ProtectedRoute.jsx
···66 const { isAuthenticated, loading } = useAuth();
77 const location = useLocation();
8899- // Simple and direct redirect approach
99+ // Use a side effect to check authentication and redirect if needed
1010 useEffect(() => {
1111- // Only check after loading is complete
1111+ // If we're still loading, wait
1212 if (loading) {
1313- console.log('ProtectedRoute: Still loading auth status...');
1313+ console.log('ProtectedRoute: Waiting for auth to complete...');
1414 return;
1515 }
16161717- // If not authenticated, redirect directly via window.location
1717+ // If not authenticated, redirect immediately
1818 if (!isAuthenticated) {
1919- console.log('ProtectedRoute: Not authenticated, redirecting to login...');
1919+ console.log('ProtectedRoute: Not authenticated, forcing redirect to login...');
2020 const redirectUrl = `/login?returnUrl=${encodeURIComponent(location.pathname + location.search)}`;
2121- window.location.href = redirectUrl;
2121+2222+ // Force redirect - this is the simplest, most reliable approach
2323+ window.location.replace(redirectUrl);
2224 } else {
2323- console.log('ProtectedRoute: User is authenticated, rendering content');
2525+ console.log('ProtectedRoute: User is authenticated, allowing access');
2426 }
2525- }, [isAuthenticated, loading, location]);
2727+ }, [isAuthenticated, loading, location.pathname, location.search]);
26282727- // Show loading state while checking auth
2929+ // Keep the component simple - only render children if authenticated
2830 if (loading) {
2929- return <div className="auth-loading">Checking authentication status...</div>;
3131+ return <div className="auth-loading">Checking authentication...</div>;
3032 }
3131-3232- // Show redirecting state if not authenticated
3333+3334 if (!isAuthenticated) {
3434- return <div className="auth-redirecting">Redirecting to login...</div>;
3535+ return <div className="auth-redirecting">Not authenticated - redirecting to login...</div>;
3536 }
36373737- // User is authenticated, render children
3838 return children;
3939};
4040
+22-5
src/components/Verifier/Verifier.js
···644644 if (isAuthLoading) return <p>Loading authentication...</p>;
645645 if (authError) return <p>Authentication Error: {authError}. <a href="/login">Please login</a>.</p>;
646646647647- // Simple auth check for debugging - this should never actually render if ProtectedRoute is working
648648- if (!session) {
649649- console.log('Verifier: Session missing, should be redirected by ProtectedRoute');
650650- return <p>You need to be logged in to use the Verifier. Redirecting...</p>;
647647+ // Direct redirect for unauthenticated users as a backup
648648+ if (!isAuthenticated) {
649649+ console.log('Verifier: Detected unauthenticated user, forcing redirect');
650650+651651+ // Force redirect as an additional failsafe
652652+ setTimeout(() => {
653653+ const redirectUrl = `/login?returnUrl=${encodeURIComponent(window.location.pathname)}`;
654654+ window.location.replace(redirectUrl);
655655+ }, 100);
656656+657657+ return <p>Authentication required. Redirecting to login...</p>;
658658+ }
659659+660660+ // Verify we have a valid session
661661+ if (!session || !session.did) {
662662+ console.log('Verifier: Session invalid, forcing redirect');
663663+ window.location.replace('/login');
664664+ return <p>Session invalid. Redirecting to login...</p>;
651665 }
652666653667 const isAnyOperationInProgress = isVerifying || isRevoking || isLoadingVerifications || isLoadingNetwork || isCheckingValidity;
···657671 <div className="verifier-intro-container">
658672 <h1>Bluesky Verifier Tool</h1>
659673 <p className="verifier-intro-text">
660660- With Bluesky's new decentralized verification system, anyone can verify anyone else and any Bluesky client can choose which accounts to treat as "Trusted Verifiers". Try verifying an account for yourself or check to see who has verified you! It's as simple as creating a verification record in your PDS that points to the account you want to verify.
674674+ With Bluesky's new decentralized verification system, anyone can verify anyone else and any Bluesky client can choose which accounts to treat as "Trusted Verifiers".
675675+ </p>
676676+ <p className="verifier-intro-text">
677677+ Try verifying an account for yourself or check to see who has verified you! It's as simple as creating a verification record in your PDS that points to the account you want to verify.
661678 </p>
662679 </div>
663680
+7
src/contexts/AuthContext.js
···139139 loading,
140140 hasError: !!error
141141 });
142142+143143+ // Force a page refresh if session state changes and we're on a protected path
144144+ // This ensures the latest auth state is always used for route protection
145145+ if (!loading && window.location.pathname === '/verifier' && !session) {
146146+ console.log('(AuthProvider) No session on protected page, forcing refresh');
147147+ window.location.reload();
148148+ }
142149 }, [session, loading, error]);
143150144151 return (