How to make content rendered dynamically. #5160
Replies: 1 comment
-
To conditionally show different content in your HTML file based on whether the user is logged in or not, you can follow these steps:
{{#if isLoggedIn}}
<!-- Show user section with options -->
<div>Users section with options</div>
{{else}}
<!-- Show login form -->
<div>Login form</div>
{{/if}}
As for packages that can help with user authentication in Express, you can consider using popular ones like Passport.js or express-session. These packages can simplify the process of handling user authentication and managing session data. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone. I am stuck with something in Express.
The thing is. I have a HTML file rendered with (hbs) engine.
In this file I have two divs:
I want one of those divs to appear on the page. If the user has already logged in, only the user section should appear, Otherwise if the user hasn't yet the log-in form should appear only.
I tried to use handlebars Helpers, but it does not give a proper result after page refresh.
What approch I should use to make it work properly. Is there a package that can do the job.
Please, help me out,
Kindly.
Beta Was this translation helpful? Give feedback.
All reactions