Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python A Social Network with Flask Broadcasting Add Some Layout

justlevy
justlevy
4,891 Points

{% if current_user.is_authenticated %}

To save someone time, be sure to turn off 'Browser Cookie Blockers' or 'Brave Shields' or anything similar.

I was having trouble setting {% if current_user.is_authenticated %} to True to show the username on the webpage.

Hope this helps someone!

This is relevant to this code in layouts.html:

<div class="grid-33">
<!-- Say Hi -->

<h1>Hello{% if current_user.is_authenticated %} {{ current_user.username }} {% endif %}</h1>

</div>

            <div class="grid-33">

                <!-- Log in/Log out -->
                {% if current_user.is_authenticated %}
                <a href="{{ url_for('logout') }}" class="icon-power" title="Log out">Log Out</a>
                {% else %}
                <a href="{{ url_for('login') }}" class="icon-power" title="Log in">Log In</a>
                <a href="{{ url_for('register') }}" class="icon-profile" title="Register">Register</a>
                {% endif %}
            </div>

          </div>

        </header>

1 Answer