Skip to content

Commit

Permalink
[GREEN] Finishing logout feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesSetiawan committed Feb 22, 2024
1 parent 4215204 commit 4eae1f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion authentication/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@

urlpatterns = [
path('register/', RegisterView.as_view(), name='register'),
path('login/', LoginView.as_view(), name='login')
path('login/', LoginView.as_view(), name='login'),
path('logout/', LogoutView.as_view(), name='logout')
]
8 changes: 7 additions & 1 deletion authentication/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from django.http import JsonResponse
from authentication.models import *
from django.contrib.auth import authenticate, login
from django.contrib.auth import authenticate, login, logout
from django.views import View
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
Expand Down Expand Up @@ -36,6 +36,12 @@ def post(self, request):
else:
return JsonResponse({'msg': 'Wrong username/password!'}, status=400)

@method_decorator(csrf_exempt, name='dispatch')
class LogoutView(View):
def post(self, request):
logout(request)
return JsonResponse({'msg': 'berhasil logout'}, status=200)

class Validators():
def validateInput(username, email, password):
if username == '' or password == '' or email == '':
Expand Down

0 comments on commit 4eae1f2

Please sign in to comment.