Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
Redirect after logging in with $auth in nuxtjs

I'm having trouble redirecting my user when logging in with nuxt's default $auth configuration. Here's my problem:

  • Whenever I log in using the laravel/jwt provider, it redirects to my website home.
  • I have several points on the site where I need to open a modal with my login and I need to keep the user logged in on the same page he is on.
  • But I already tried to follow the documentation using the fake redirect flag and still I couldn't.

Is there any way to log in, if he is not on a specific page, such as the login page, he just refreshes instead of redirecting to the / route?

My usage:

async login() {
      try {
        this.loading(true)
        await this.$auth.loginWith('laravelJWT', { data: this.form })
        if (!this.redirectHome) {
          this.$router.back()
          this.$emit('is-logged')
        }
      } catch (error) {
        this.loginError = true
      } finally {
        this.loading(false)
      }
    },
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

My resolution:

async login() {
      await this.$auth
        .loginWith('laravelJWT', { data: this.form })
        .then(() => {
          this.loading(true)
          if (this.$route.name !== 'login') {
            this.$router.go(this.$router.currentRoute)
          }
          this.$emit('is-logged')
        })
        .catch(() => {
          this.loginError = true
        })
        .finally(() => {
          this.loading(false)
        })
    },
about 4 years ago · Juan Pablo Isaza Relatório

0

use this.$auth.options.redirect = false before loginWith it will disable redirect. when the promise resolved then you can call other api to refresh data or do whatever you want.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda