Hi,
I’m building a user dashboard and would like to hide the login button in the navbar.
I have created a Server Action that returns the current user identity:
I have set the master page to call such Server Action, through a Server Connect element:
And, finally, I’m hiding the Login button when an identity is present:
<div class="navbar-nav ms-auto" dmx-hide="serverconnect1.data.identity">
<a class="nav-item nav-link" href="login">Login</a>
</div>
This works, it hides the element after an API call to obtain the user identity.
However, during page load, there’s a moment where the server connect API call hasn’t performed yet, and therefore the user could see such element for a few milliseconds before being hidden.
Is it possible to hide this element server-side? I understand we can use EJS conditions, but I’m unsure what condition I should input to verify if the user is logged in already. Certainly I can’t use “serverconnect1.data.identity” because this is a client-side variable.
Has anyone attempted this scenario server-side?