Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there is a way to get route from we redirected to login ? #642

Closed
zorn-v opened this issue Mar 22, 2021 · 2 comments
Closed

Is there is a way to get route from we redirected to login ? #642

zorn-v opened this issue Mar 22, 2021 · 2 comments

Comments

@zorn-v
Copy link
Contributor

zorn-v commented Mar 22, 2021

Assume that we have routes like this

const routes = [
  { path: '/login', name: 'login', component: Login, meta: {auth: false} },
  { path: '/', redirect: {name: 'profile'}, component: Layout, meta: {auth: true}, children: [
    { path: '/profile', name: 'profile', component: Profile },
    { path: '/parameters', name: 'parameters', component: Parameters },
  ] },
  { path: '*', redirect: {name: 'profile'} }
]

If we directly open /parameters route, we will be redirected to login page, and after success login, redirected to /profile
But I want to save original route we opened (via link or directly in address bar etc.) and redirect to it after success login.

I can add beforeEach hook on router and save (in some store) "last route if it not login", but this way not looks good to me.
Is there is a better way to do it ?

@websanova
Copy link
Owner

@zorn-v have you taken a look at this yet?

https://websanova.com/docs/vue-auth/methods/core#redirect

@zorn-v
Copy link
Contributor Author

zorn-v commented Mar 23, 2021

Thanks a lot. It is exactly what I need.

@zorn-v zorn-v closed this as completed Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants