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

254
Visualizações
Nuxt.js loginWith Auth0 delayed redirect

I have the following setup with Auth0 & Nuxt.js. Somehow after loginWith, the page still continues to render for a brief moment before redirecting to Auth0's login page. The promise returned from loginWith is undefined, which makes blocking on it impossible. Is there a way to immediately proceed with Auth0 login without rendering the page first?

if (!this.$auth.loggedIn) {
  await this.$auth.loginWith("auth0");
}
const user = this.$auth.user;
// Operations using user information below //
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

First of all you should not block rendering until some asynchronous operation complete. Basically the async call to a function decorated with "await" is required to let the UI thread to do its job. Instead of blocking rendering you should display some useful information for the user, at least some message that describes the process being performed: "Authorizing..." or something like this.

To resolve you problem you can declare some boolean variable in your component (or in your vuex store) that is set to false until user is authorized. By checking this value in your html template you can prevent showing page content until browser is redirected to auth page.

data() {
  return {
    isAuthorized: false;
  }
}

// your code
if (!this.$auth.loggedIn) {
  await this.$auth.loginWith("auth0");
} else {
  this.isAuthorized = true;
}

// process user information
over 4 years ago · Santiago Trujillo Relatório

0

The 'await this.$auth.loginWith("auth0");' is causing the breif moment of delay. This is the time required to verify if the current session is active. This can be handled by adding something like a loading page.

showLoadingPage(); // display a fullscreen loading animation or text
if (!this.$auth.loggedIn) {
  await this.$auth.loginWith("auth0");
}
hideLoadingPage(); // hide the loading animation after the await completes

const user = this.$auth.user;
// Operations using user information below //
over 4 years ago · Santiago Trujillo 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