Detect Admin Is Logged In

Instructions

  1. Place the following before the closing </head> tag.
  2. Assign theLandingPageId variable, the id of the root page (request.request_url.origin)

{% assign theLandingPageId = XXXX %}
{% unless this.id == theLandingPageId %} 
    <script>
        var isAdminUserLogged = Boolean(localStorage.getItem("user"));
        var landingPage = "{{ request.request_url.origin }}";
        if(!isAdminUserLogged) {
            location.replace(landingPage)
        }
    </script>
{% endunless %}

How does it work?

It detects if a user is logged in. Treepl places user data in your browser's localStorage when a user is logged in.

(both admin and partner)