Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

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?


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


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



The exploration of ethos pathos logos https://writepaper.com/blog/ethos-pathos-and-logos offered a masterclass in the foundational elements of persuasion. This guide skillfully demystifies how these rhetorical strategies can be effectively employed in writing to engage and convince the audience, highlighting their timeless relevance in crafting compelling arguments


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(