Skip to content

Commit

Permalink
Added logout functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
joisemp committed Apr 2, 2024
1 parent 43b289d commit 6a7141a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/templates/core/logout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>You have been logged out</h1>
<a href="{% url 'landing-page' %}">Home page</a>
1 change: 1 addition & 0 deletions core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

urlpatterns = [
path('login/', views.LoginView.as_view(), name='login'),
path('logout/', views.LogoutView.as_view(), name='logout'),
]
3 changes: 3 additions & 0 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ def form_valid(self, form):
if remember_me:
self.request.session.set_expiry(1209600)
return redirect('landing-page')

class LogoutView(views.LogoutView):
template_name = 'core/logout.html'
5 changes: 3 additions & 2 deletions templates/landing_page.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<h1>Landing Page</h1>
{% if user.is_authenticated %}
<p>{{user.email}}</p>
<p>{{user.email}}</p>
<p>To logout <a href="{% url 'core:logout' %}">Click here</a></p>
{% else %}
<p>Not logged in</p>
<p>Not logged in <a href="{% url 'core:login' %}">Login</a></p>
{% endif %}

0 comments on commit 6a7141a

Please sign in to comment.