updated routes for ForgotPassword
This commit is contained in:
47
src/App.tsx
47
src/App.tsx
@@ -8,10 +8,10 @@ import ForgotPassword from "./Pages/ForgotPassword";
|
||||
import VerifyEnterOTP from "./Pages/VerifyEnterOTP";
|
||||
import SetNewPassword from "./Pages/SetNewPassword";
|
||||
|
||||
function App() {
|
||||
const context = useContext(GlobalStateContext);
|
||||
if (!context) throw new Error("App must be used within a GlobalStateProvider");
|
||||
|
||||
function App() {
|
||||
const context = useContext(GlobalStateContext);
|
||||
if (!context) throw new Error("App must be used within a GlobalStateProvider");
|
||||
|
||||
const { isAuthenticate, setIsAuthenticate } = context;
|
||||
|
||||
useEffect(() => {
|
||||
@@ -21,19 +21,19 @@ function App() {
|
||||
|
||||
console.log("Auth Status:", isAuthenticate);
|
||||
|
||||
return (
|
||||
<Router>
|
||||
<Routes>
|
||||
return (
|
||||
<Router>
|
||||
<Routes>
|
||||
{/* Redirect logged-in users away from login */}
|
||||
<Route path="/login" element={isAuthenticate && localStorage.getItem("token") ? <Navigate to="/" /> : <Login />} />
|
||||
<Route path="/login" element={isAuthenticate && localStorage.getItem("token") ? <Navigate to="/" /> : <Login />} />
|
||||
<Route path="/forgot-password" element={<ForgotPassword />} />
|
||||
<Route path="/forgot-password/verify-otp" element={<VerifyEnterOTP />} />
|
||||
<Route path="/forgot-password/reset-password" element={<SetNewPassword />} />
|
||||
|
||||
{/* Protected Routes */}
|
||||
<Route
|
||||
path="/*"
|
||||
element={isAuthenticate && localStorage.getItem("token") ? (
|
||||
<Route
|
||||
path="/*"
|
||||
element={isAuthenticate && localStorage.getItem("token") ? (
|
||||
<DefaultLayout>
|
||||
<Routes>
|
||||
{RouteLink.map(({ path, Component }, index) => (
|
||||
@@ -42,15 +42,24 @@ function App() {
|
||||
</Routes>
|
||||
</DefaultLayout>
|
||||
) : (
|
||||
<Navigate to="/login" />
|
||||
)}
|
||||
/>
|
||||
<Routes>
|
||||
{/* Allow only forgot password flows */}
|
||||
<Route path="/forgot-password" element={<ForgotPassword />} />
|
||||
<Route path="/forgot-password/verify" element={<VerifyEnterOTP />} /> {/* ✅ Add this line */}
|
||||
<Route path="/forgot-password/verify-otp" element={<VerifyEnterOTP />} />
|
||||
<Route path="/forgot-password/reset-password" element={<SetNewPassword />} />
|
||||
|
||||
{/* Default to login */}
|
||||
<Route path="*" element={<Navigate to="/login" />} />
|
||||
</Routes>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Catch-all route to prevent unauthorized access */}
|
||||
<Route path="*" element={<Navigate to="/login" />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
<Route path="*" element={<Navigate to="/login" />} />
|
||||
</Routes>
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
||||
Reference in New Issue
Block a user