Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logout functionality #12

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %}
Loading