Add logout

This commit is contained in:
2025-12-12 11:09:55 +05:30
parent 07dcb72deb
commit 5c0289e715
5 changed files with 13 additions and 1 deletions

View File

@@ -136,3 +136,4 @@ REST_FRAMEWORK = {
LOGIN_URL = "login"
LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "login"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -28,6 +28,12 @@ header img {
margin: 20px;
}
.logout {
padding: 0;
background: transparent;
border: none;
}
main {
padding: 0 30px;
}

View File

@@ -16,6 +16,10 @@
<a href="{% url "profile" %}">
<img src="{% static "notes/images/icons/profile.png" %}" alt="Profile" title="Profile" />
</a>
<form method="post" action="{% url "logout" %}">
{% csrf_token %}
<button class="logout"><img src="{% static "notes/images/icons/logout.png" %}" alt="Logout" title="Logout" /></button>
</form>
</header>
<main>
{% block body %}

View File

@@ -1,4 +1,4 @@
from django.contrib.auth.views import LoginView
from django.contrib.auth.views import LoginView, LogoutView
from django.urls import include, path
from notes import views, api_views
@@ -9,6 +9,7 @@ urlpatterns = [
path("post-a-note/", views.PostNoteView.as_view(), name="post-a-note"),
path("profile/", views.ProfileView.as_view(), name="profile"),
path("login/", LoginView.as_view(), name='login'),
path("logout/", LogoutView.as_view(), name='logout'),
path("api/notes/", api_views.NoteListView.as_view(), name="api-notes-list"),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
]