This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

add allowlist

+35 -6
+9 -3
src/components/ProtectedRoute.js
··· 1 1 import React from 'react'; 2 2 import { Navigate } from 'react-router-dom'; 3 3 import { useAuth } from '../contexts/AuthContext'; 4 + import { isAccountAllowed } from '../config/allowlist'; 4 5 import Loading from './Loading/Loading'; 5 6 6 7 // Component to protect routes that require authentication 7 8 const ProtectedRoute = ({ children }) => { 8 - const { isAuthenticated, loading } = useAuth(); 9 + const { isAuthenticated, loading, session } = useAuth(); 9 10 10 11 // Show loading state while authentication is being checked 11 12 if (loading) { 12 13 return <Loading message="Checking authentication..." />; 13 14 } 14 15 15 - // Redirect to login if not authenticated 16 + // If not authenticated, redirect to login 16 17 if (!isAuthenticated) { 17 18 return <Navigate to="/login" replace />; 18 19 } 19 20 20 - // Render children if authenticated 21 + // If authenticated but not allowed, redirect to supporter page 22 + if (!isAccountAllowed(session)) { 23 + return <Navigate to="/supporter" replace />; 24 + } 25 + 26 + // Render children if authenticated and allowed 21 27 return children; 22 28 }; 23 29
+14
src/config/allowlist.js
··· 1 + // List of allowed DIDs and usernames 2 + export const ALLOWED_ACCOUNTS = [ 3 + 'did:plc:gq4fo3u6tqzzdkjlwzpb23tj', // Dame's DID 4 + 'dame.is' // Dame's handle 5 + ]; 6 + 7 + // Helper function to check if an account is allowed 8 + export const isAccountAllowed = (session) => { 9 + if (!session) return false; 10 + 11 + // Check both DID and handle 12 + return ALLOWED_ACCOUNTS.includes(session.sub) || 13 + ALLOWED_ACCOUNTS.includes(session.handle); 14 + };
+12 -3
src/contexts/AuthContext.js
··· 85 85 // Logout the user 86 86 const logout = async () => { 87 87 if (!client || !session) { 88 - console.log('No client or session available for logout'); // Debug log 88 + console.log('No client or session available for logout'); 89 89 return; 90 90 } 91 91 92 92 try { 93 - console.log('Attempting logout with client:', client); // Debug log 94 - // Instead of using client methods, we'll just clear the session 93 + console.log('Attempting logout with client:', client); 94 + 95 + // Clear the session state 95 96 setSession(null); 97 + 96 98 // Clear any stored tokens or session data 97 99 localStorage.removeItem('atproto_session'); 100 + 101 + // Clear any other potential storage items 102 + localStorage.removeItem('atproto_state'); 103 + localStorage.removeItem('atproto_refresh_token'); 104 + 105 + // Force a page reload to clear any remaining state 106 + window.location.href = '/'; 98 107 } catch (err) { 99 108 console.error('Logout failed:', err); 100 109 setError(err.message);