Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Vue - User Sign in


How to redirect from sign-in to dashboard if user logged in??


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (5)


Hi Uzzal,

It should be done by default, all users will be redirected to the dashboard page after successful login.

You can change the default page in file src/views/crafted/authentication/basic-flow/SignIn.vue.

router.push({ name: "dashboard" });



I understand this. My question was:
If the user is already logged-in then how can I redirect user to "dashboard" if he tries to visit the "sign-in" page?

In current scenario:
If the user is logged-in, still able to visit "sign-in" page and type login credentials.



Hi,

You can implement this in file src/components/page-layouts/Auth.vue

Inside the mounted function check if user is authenticated and if he is already authenticated you can redirect the user to a dashboard page.

onMounted(() => {
if (store.getters.isUserAuthenticated) {
router.push({ name: "dashboard" });
}
});


Your Support Matters!

We will highly appreciate your Metronic Review on Themeforest.
Please go to Themeforest Downloads page, select Metronic & leave your feedback.

Isn’t it default behavior?



Yes, it is default behavior for all Vue demos.


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(