Logout Link on Lightning Community

Currently I am working on the community implementation and I come accross the scenario where I need to place a logout link on the community page. On google most of them mention to redirect logout.jsp page. When I use this logout.jsp page it is just redirecting to the logout page without clearing the session. Then I started going through the salesforce documentation and came across the below Lightning Web Component(LWC) for the logout link.

LogoutPage.js 


This code will clear the session and redirect to the community login screen. To make this code work 100% in your community then you have to follow the below steps. 

 1. Your community should not be a public facing. 
 2. On the community setting Login and Logout pages should be set as default pages. 

I hope this will help. Please let me know your thoughts.

No comments:

Post a Comment