Auth menu in Base template
Some things we need to see in all pages are global navigation and information and links from authentication system. Let's create second one. With Flask-Login it is pretty simple. It offers us current_user variable accessible in all templates. To show current user information in all pages we need to modify our base template.
Here is a part of code I've added to header and with some style improvements.
...
<div class="c-header">
<div class="slds-grid">
<div class="slds-col">
<span class="slds-icon_container slds-icon-custom-custom5" title="Description of icon when needed">
<svg style="width: 50px; height:50px;" class="slds-icon" aria-hidden="true">
<use xlink:href="/static/slds/icons/custom-sprite/svg/symbols.svg#custom5"></use>
</svg>
</span>
<h1 class="c-header-title">Salesforce Backup Service</h1>
</div>
<div class="slds-col">
<div class="c-auth-subheader">
{% if current_user.is_authenticated %}
<span>You are logged in as <b>{{ current_user.username }}</b> | <a href="/auth/logout">Logout</a></span>
{% else %}
<a href="/auth/login">Login</a></span>
{% endif %}
</div>
</div>
</div>
</div>
...
Comments
Post a Comment