Add login, logout to navbar

This commit is contained in:
Maxime Bloch 2020-07-22 15:10:49 +02:00
parent 2f50efb5d4
commit 8668413a58
4 changed files with 38 additions and 8 deletions

View file

@ -3,7 +3,8 @@ from django.urls import path
from . import views
app_name = "oauth"
urlpatterns = [
path('register', views.register),
path('register', views.register, name='login'),
path('authorized', views.register_callback),
]

View file

@ -28,9 +28,9 @@
nav li {
list-style-type: none;
display: inline-block;
margin: 0 2vw;
margin: 0 1.5vw;
/* 3% of the height of the viewport */
font-size: 3vh;
font-size: 2vh;
}
nav a {
@ -90,13 +90,24 @@
margin: 8px 0;
box-sizing: border-box;
}
.alignLeft {
float: left;
}
.alignRight {
float: right;
}
.accentuated {
color: #66351d;
}
</style>
</head>
<body>
<nav>
<button id="nav-button"></button>
<ul>
<ul class="alignLeft">
<li>
<a href="{% url 'events:index' %}">
Home</a>
@ -107,6 +118,26 @@
</a>
</li>
</ul>
<ul class="alignRight">
{% if user.is_authenticated %}
<li class="accentuated">
Hello, {{ user.username }}
</li>
<li>
<a href="{% url 'users:logout' %}">
Logout
</a>
</li>
{% else %}
<li>
<a href="{% url 'oauth:login' %}">
Login
</a>
</li>
{% endif %}
</ul>
<div style="clear: both;"></div>
</nav>
<h1>Zeus WPI Kelderregistratiesysteem™</h1>
<main>

View file

@ -11,10 +11,8 @@
<label>Real name</label>
<input type="text" value="{{ user.real_name }}">
<input type="submit" value="Save"/>
<a href="/user/logout">Logout</a>
{% else %}
<p>Not logged in</p>
<a href="/login/zeus/register">Login</a>
{% endif %}
{% endblock %}

View file

@ -6,5 +6,5 @@ app_name = "users"
urlpatterns = [
path('profile', views.profile, name="profile"),
path('logout', views.logout_view)
path('logout', views.logout_view, name="logout")
]