Logout from ERPNext Website

I am trying to develop a website, using a template/theme of my own. I have the “logout” button. How to add the functionality to logout and go back to login page while clicking the button.


This is the logout button. I have added the template html and python file inside “www” folder of my custom app.

This is how I do it in a custom template I’m currently working on.

    {% if frappe.session.user != 'Guest' %}
         <div class="top_bar_contact_item ml-auto">
               <a style="cursor: pointer" onclick="return frappe.app.logout()">Logout</a>
         </div>
         <div class="top_bar_contact_item">
               <a href="/me">My Account</a>
         </div>
   {% else %}
         <div class="top_bar_contact_item ml-auto">
               <a href="/login">Log In</a>
        </div>
   {% endif %}

Hope that helps.

1 Like