【发布时间】:2021-11-25 13:03:03
【问题描述】:
问题:
使用 msal v2,当用户通过 Microsoft 帐户登录应用程序时,它会将参数保存到 sessionStorage 并且一切正常,当用户在 Office.com 或使用 Microsoft SSO 的任何其他站点注销时会出现问题.由于数据仍保存在sessionStorage 中(尝试与localStorage 相同),因此AcquireSilentToken(...) 使用缓存的数据进行解析,即使用户已注销。
试过How to know if a given user is already logged in with MSAL?
它建议使用AcquireSilentToken(...),但由于它检查了sessionStorage,因此它可以正确解析promise。
我的情况:
在我想做的中间件中:
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')
});
所以如果有人可以帮助我通过询问用户是否已注销的方式。我真的很感激。
【问题讨论】:
标签: javascript node.js vue.js microsoft-graph-api msal