Skip to content

Commit

Permalink
route protect -done
Browse files Browse the repository at this point in the history
  • Loading branch information
VidwaDeSeram committed Jan 4, 2024
1 parent 35f804f commit bca1b09
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function App() {
function ProtectedRoute({ children }) {
const isLoggedIn = useSelector((state) => state.auth.isLoggedIn);
const token = localStorage.getItem("token");
if (!isLoggedIn & token) {
if (!isLoggedIn & !token) {
Swal.fire({
title: "Unauthorized Access",
text: "You need to log in to access this page",
Expand Down Expand Up @@ -119,7 +119,14 @@ function App() {
}
/>
<Route path="/not-found" Component={NotFound} />
<Route path="/payment-success" Component={PaymentSuccess} />
<Route
path="/payment-success"
element={
<ProtectedRoute>
<PaymentSuccess />
</ProtectedRoute>
}
/>
</Routes>
<Footer />
</Router>
Expand Down

0 comments on commit bca1b09

Please sign in to comment.