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

330
Visualizações
Msal v2 library, handle logout for SSO (Node.js and Vue.js)

The problem:

Using msal v2, when user log in to the app via Microsoft account, it saves params to the sessionStorage and it all works great, problem happens when user logs out in the Office.com or any other site using Microsoft SSO. Since the data is still saved in sessionStorage (tried same with localStorage) the AcquireSilentToken(...) resolves with the cached data, even though the user has been logged out.

Tried How to know if a given user is already logged in with MSAL?

It suggest using AcquireSilentToken(...) but it resolves promise without error since it checks sessionStorage.

My case:

In the middleware I would like to do:

const promise = msalInstance.acquireTokenSilent(graphScopes);
  promise.then(resp=>{
    //User is logged continue next();
      }).catch(error=>{
    //User is not logged in clear sessionStorage/localStorage and next('/login')
  });

So if anyone can help me with the way of asking the thru msal if user has logged out. I would really appreciate it.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This behavior is by design. AAD services uses cookies to remember who you are and to automatically sign you in.

The sign-out process for services forces the session cookies to expire. These session cookies are used to maintain your sign-in state when you use these services. However, because the web browser is still running and may not be updated to handle cookies correctly, you may have a cookie that is not updated to expire and finish the sign-out process. By default, these cookies are valid for eight hours or are set to expire when you close all web browsers.

const promise = msalInstance.acquireTokenSilent(graphScopes);
  promise.then(resp=>{
    const logoutRequest = {
           account: instance.getAccountByHomeId(homeAccountId),
    postLogoutRedirectUri: "your_app_logout_redirect_uri"
}
instance.logoutRedirect(logoutRequest);
  }).catch(error=>{
//User is not logged in clear sessionStorage/localStorage and next('/login')

});

Also this is a known issue.

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