How to redirect to a custom router?

hojas
10
hojas
commented 6 months ago

What problem does this feature solve?

In nuxt.config.js I set this:

auth: {
    redirect: {
      login: '/login/',
      callback: '/login/',
      home: '/',
    },
}

Always redirect to home page after login, in some page that is not required auth. But in this case, I want to redirect to a custom page such as current page. And there is no login page in my app, only a login form in a modal. I am using bootstrap.

What does the proposed changes look like?

Hope that I can redirect to a custom page not the auth module specified in nuxt.config.js. Or that will be great if I can set the redirect dynamic.

idea
0
xtrasmal
0
xtrasmal
commented 5 months ago
  1. If you redirect to the same page where you came from, then you can do a check.
    example pseudo: if user is logged in, then $router.push('where/ever')

  2. You can create a page called: after-login.vue. This will be the page where you redirect to, always.

  3. Store the current page or the redirect in the store. It does not matter where you are. After a successful login, you redirect to $router.push(this.$store.state.lazybrain.storedRoute)) or whatever place you invented.

And there probably are some more interesting approaches thinkable. Therefore..I think it is not needed to ask for a feature request.

0
hojas
10
hojas
commented 5 months ago

@xtrasmal Thanks so much.

0
Informations
Feature Request โ€ข Open
#c246 - Created 6 months ago