Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
main.handlebars #if loggedIn

I have tested everything. My logout button should appear and disappear based on the user's logged in session. Can someone please test and help me figure out whats going wrong? IF you look at my repository please review code in feature/iflogout

link to repository: https://github.com/Brainybrian316/Sweet-Nostalgia

This is a small idea of what the handlebars looks like. its too much code to post here so please checkout the repository. Any tips or advice will do.

     {{#if loggedIn}}
                        <li class="nav-item">
                            <button id="logout" type="button" class="nav-link btn btn-link">Logout</button>
                        </li>
                        {{else}}
                        <li class="nav-item">
                            <a class="nav-link" href="/login">Login</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="/signup">Signup</a>
                        </li>
                        {{/if}}
                    </ul>
                </div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

ISSUE RESOLVED.... In my home-routes.js when we would render the home page the file looked as such:

router.get('/', (req, res) => { 
res.render('homepage');

I added

{loggedIn: req.session.loggedIn}

be place within the res.render() which now looks like this:

//GET home page
router.get('/', (req, res) => { // anyone can access this page
    //  home.handlebars file
    res.render('homepage', {loggedIn: req.session.loggedIn});

Now the button will come and go :D but I also had to change the dashboard route to this:

router.get('/', withAuth, (req, res) => { 
    // home.handlebars file
    res.render('dashboard', {loggedIn: true });
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!