Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

333
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda