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 from . import views
app_name = "oauth"
urlpatterns = [ urlpatterns = [
path('register', views.register), path('register', views.register, name='login'),
path('authorized', views.register_callback), path('authorized', views.register_callback),
] ]

View file

@ -28,9 +28,9 @@
nav li { nav li {
list-style-type: none; list-style-type: none;
display: inline-block; display: inline-block;
margin: 0 2vw; margin: 0 1.5vw;
/* 3% of the height of the viewport */ /* 3% of the height of the viewport */
font-size: 3vh; font-size: 2vh;
} }
nav a { nav a {
@ -90,13 +90,24 @@
margin: 8px 0; margin: 8px 0;
box-sizing: border-box; box-sizing: border-box;
} }
.alignLeft {
float: left;
}
.alignRight {
float: right;
}
.accentuated {
color: #66351d;
}
</style> </style>
</head> </head>
<body> <body>
<nav> <nav>
<button id="nav-button"></button> <button id="nav-button"></button>
<ul> <ul class="alignLeft">
<li> <li>
<a href="{% url 'events:index' %}"> <a href="{% url 'events:index' %}">
Home</a> Home</a>
@ -107,10 +118,30 @@
</a> </a>
</li> </li>
</ul> </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> </nav>
<h1>Zeus WPI Kelderregistratiesysteem™</h1> <h1>Zeus WPI Kelderregistratiesysteem™</h1>
<main> <main>
{% block content %}{% endblock %} {% block content %}{% endblock %}
</main> </main>
<script> <script>
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {

View file

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

View file

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