Microsoft-authentication-library-for-js: Issue with logout. User should have to login again if he closes browser window. How to logout user on closing browser.

Created on 26 Mar 2019  路  3Comments  路  Source: AzureAD/microsoft-authentication-library-for-js

Current behavior

User is able to login to application using the msal npm package and perform operations. Login and logout etc working fine. but if user close the browser tab and again open it still user is logged in.

Expected behavior

Is there any method for this or have to add custom event to capture onunload and then clear the localStorage ?

bug documentation

Most helpful comment

You shouldn't be using localStorage if you want this sort of functionality. Passing the value 'sessionStorage' as the cacheLocation parameter when instantiating the UserAgentApplication will get you closer to what you want. The documentation on these parameters can be found in the wiki.

All 3 comments

You shouldn't be using localStorage if you want this sort of functionality. Passing the value 'sessionStorage' as the cacheLocation parameter when instantiating the UserAgentApplication will get you closer to what you want. The documentation on these parameters can be found in the wiki.

You shouldn't be using localStorage if you want this sort of functionality. Passing the value 'sessionStorage' as the cacheLocation parameter when instantiating the UserAgentApplication will get you closer to what you want. The documentation on these parameters can be found in the wiki.

sessionStorage will store the session only for the tab where user is logged in and if the user open application in another tab or click any link in app to open in new tab he have to login again as sessionStorage is tabs specific. So what to do in such case

@AbhaysinghBhosale What you seem to require us to clear 'localStorage' on exit which is beyond the functionality of this library. You may be able to clear the 'localStorage' on the exit of the window from the application end.

Closing this issue.

Was this page helpful?
0 / 5 - 0 ratings