Added Login and Logout buttons to NavBar

This commit is contained in:
Oliver 2018-05-08 23:09:52 +10:00
parent 47aa3c8a45
commit 3cf45f5ed3
2 changed files with 13 additions and 1 deletions

View File

@ -47,7 +47,7 @@ urlpatterns = [
url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^login/', auth_views.login, name='login'),
url(r'^logout/', auth_views.logout, name='logout'),
url(r'^logout/', auth_views.logout, {'template_name': 'registration/logout.html'}, name='logout'),
url(r'^admin/', admin.site.urls),
url(r'^api/', include(apipatterns)),

View File

@ -11,5 +11,17 @@
<li><a href="{% url 'build-index' %}">Build</a></li>
<li><a href="{% url 'company-index' %}">Companies</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
{% if user.is_authenticated %}
<li class='dropdown'>
<a class='dropdown-toggle' data-toggle='dropdown' href="#"><span class="glyphicon glyphicon-user"></span>{{ user.get_username }}</a>
<ul class='dropdown-menu'>
<li><a href="{% url 'logout' %}">Logout</a></li>
</ul>
</li>
{% else %}
<li><a href="{% url 'login' %}"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
{% endif %}
</ul>
</div>
</nav>