fix: add pre-auth session clear mechanism on HomePage (refs #192)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,9 +6,10 @@ import { FeaturesGrid } from './HomePage/FeaturesGrid';
|
||||
import { motion } from 'framer-motion';
|
||||
|
||||
export const HomePage = () => {
|
||||
const { loginWithRedirect, isAuthenticated } = useAuth0();
|
||||
const { loginWithRedirect, isAuthenticated, logout } = useAuth0();
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
const [isScrolled, setIsScrolled] = useState(false);
|
||||
const [sessionCleared, setSessionCleared] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -41,6 +42,22 @@ export const HomePage = () => {
|
||||
navigate('/signup');
|
||||
};
|
||||
|
||||
const handleClearSession = async () => {
|
||||
try {
|
||||
const { indexedDBStorage } = await import('../core/utils/indexeddb-storage');
|
||||
await indexedDBStorage.clearAll();
|
||||
Object.keys(localStorage).forEach(key => {
|
||||
if (key.startsWith('@@auth0')) localStorage.removeItem(key);
|
||||
});
|
||||
logout({ openUrl: false });
|
||||
setSessionCleared(true);
|
||||
setTimeout(() => setSessionCleared(false), 3000);
|
||||
} catch (error) {
|
||||
console.error('[HomePage] Failed to clear session:', error);
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-nero text-avus">
|
||||
{/* Navigation Bar */}
|
||||
@@ -84,6 +101,12 @@ export const HomePage = () => {
|
||||
>
|
||||
Login
|
||||
</button>
|
||||
<button
|
||||
onClick={handleClearSession}
|
||||
className="text-white/40 hover:text-white/70 text-xs transition-colors min-h-[44px] min-w-[44px] flex items-center"
|
||||
>
|
||||
{sessionCleared ? 'Session cleared' : 'Trouble logging in?'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Mobile Menu Button */}
|
||||
@@ -149,6 +172,12 @@ export const HomePage = () => {
|
||||
>
|
||||
Login
|
||||
</button>
|
||||
<button
|
||||
onClick={handleClearSession}
|
||||
className="w-full text-white/40 hover:text-white/70 text-xs py-2 min-h-[44px] transition-colors"
|
||||
>
|
||||
{sessionCleared ? 'Session cleared' : 'Trouble logging in?'}
|
||||
</button>
|
||||
</motion.div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user