Skip to content

Commit

Permalink
Refactor: user views and URLs
Browse files Browse the repository at this point in the history
This commit refactors the user views and URLs in the backend. The `LoginView` function has been renamed to `login`, and the `RegisterUser` function has been renamed to `register_user`. The corresponding changes have also been made in the `urls.py` file. This improves code readability and follows naming conventions.
  • Loading branch information
SverreNystad committed Jan 5, 2024
1 parent 11ce031 commit aa3794a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions backend/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.urls import path

from users.views import LoginView, RegisterUser
from users.views import login, register_user
from documents.views import upload_pdf

urlpatterns = [
path("create-user/", RegisterUser, name="create-user"),
path("login/", LoginView, name="login"),
path("create-user/", register_user, name="create-user"),
path("login/", login, name="login"),
path("upload/", upload_pdf, name="upload"),
]
4 changes: 2 additions & 2 deletions backend/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
responses={200: login_success_response, 401: login_error_response},
)
@api_view(["POST"])
def LoginView(request):
def login(request):
username = request.data.get("username")
password = request.data.get("password")
user = authenticate(username=username, password=password)
Expand Down Expand Up @@ -87,7 +87,7 @@ def LoginView(request):
responses={201: register_success_response, 400: register_error_response},
)
@api_view(["POST"])
def RegisterUser(request):
def register_user(request):
serializer = RegisterSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
Expand Down

0 comments on commit aa3794a

Please sign in to comment.