How to redirect from login to menu with own API - REACT
I replaced the theme's api with our api.
I'm getting the connection, but I can't redirect to the menu after being authenticated.
I'm using the metronic demo6 - REACT theme.
Can someone help me?
Replies (1)
Hi Lohuama Lima,
To redirect user to main page you can just set current authentication with saveAuth function.
You can refer to our example in file src/app/modules/auth/components/Login.tsx.
const {saveAuth, setCurrentUser} = useAuth()saveAuth(auth)
setCurrentUser(user)
Then inside src/app/routing/AppRoutes.tsx we display routes conditionally.
const {currentUser} = useAuth(){currentUser ? (
<>
<Route path='/*' element={<PrivateRoutes />} />
<Route index element={<Navigate to='/dashboard' />} />
</>
) : (
<>
<Route path='auth/*' element={<AuthPage />} />
<Route path='*' element={<Navigate to='/auth' />} />
</>
)}
Regards,
Lauris Stepanovs,
Keenthemes Support Team