diff --git a/src/App.jsx b/src/App.jsx index 77ca1f6..5df259e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -23,6 +23,7 @@ import Login from './components/Login/Login'; import LoginCallback from './components/Login/LoginCallback'; import Verifier from './components/Verifier/Verifier'; import { AuthProvider } from './contexts/AuthContext'; +import ProtectedRoute from './components/ProtectedRoute'; import "./App.css"; const App = () => { @@ -51,7 +52,14 @@ const App = () => { } /> } /> } /> - } /> + + + + } + /> } /> } /> } /> diff --git a/src/components/Login/Login.css b/src/components/Login/Login.css index 6e51dff..2be11be 100644 --- a/src/components/Login/Login.css +++ b/src/components/Login/Login.css @@ -46,10 +46,9 @@ } .login-form { - display: flex; - flex-direction: column; - gap: 15px; - width: 100%; + background: none; + border: none; + padding: 0px; } .login-input-field { diff --git a/src/components/Login/Login.js b/src/components/Login/Login.js index bc88c02..6911ac5 100644 --- a/src/components/Login/Login.js +++ b/src/components/Login/Login.js @@ -41,13 +41,13 @@ const Login = () => {

Login to cred.blue

-

Enter your Bluesky or ATProto handle (e.g., yourname.bsky.social)

+

Enter your Bluesky or ATProto handle

{ disabled={loading} className="login-submit-button" > - {loading ? 'Processing...' : 'Login'} + {loading ? 'Processing...' : 'Login with Bluesky'}

diff --git a/src/components/ProtectedRoute.jsx b/src/components/ProtectedRoute.jsx new file mode 100644 index 0000000..88d44fc --- /dev/null +++ b/src/components/ProtectedRoute.jsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Navigate, useLocation } from 'react-router-dom'; +import { useAuth } from '../contexts/AuthContext'; + +const ProtectedRoute = ({ children }) => { + const { isAuthenticated, authLoading } = useAuth(); // Assuming 'authLoading' is the correct name from context + const location = useLocation(); + + if (authLoading) { + // Optional: Display a loading indicator while checking auth status + return

Loading authentication status...
; + } + + if (!isAuthenticated) { + // User not logged in, redirect to login page + // Preserve the original intended location in the state + return ; + } + + // User is authenticated, render the child component + return children; +}; + +export default ProtectedRoute; \ No newline at end of file