Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Commit

Permalink
Add a user logout view (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
JobDoesburg authored Apr 23, 2021
1 parent 6a75fb1 commit 64525a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion website/sagexit/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<i class="fab fa-openid"></i> Login with Science
</a>
{% else %}
<a class="nav-link" href="{% url 'admin:logout' %}?next={{ request.path | urlencode }}">You're logged in as {{ request.user }} - Log out</a>
<a class="nav-link" href="{% url 'logout' %}?next={{ request.path | urlencode }}">You're logged in as {{ request.user }} - Log out</a>
{% endif %}
</li>
</ul>
Expand Down
10 changes: 9 additions & 1 deletion website/sagexit/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
from django.contrib import admin
from django.contrib import admin, auth
from django.shortcuts import redirect
from django.urls import path, include
from django.views.generic import RedirectView


def logout(request):
auth.logout(request)
return redirect("/")


urlpatterns = [
path("", RedirectView.as_view(url="/reservations")),
path("reservations/", include("room_reservation.urls")),
path("admin/", admin.site.urls),
path("logout/", logout, name="logout"),
path("sso/", include("sp.urls")),
]

0 comments on commit 64525a8

Please sign in to comment.