Skip to content

Commit

Permalink
#4: Change how POST checks are done.
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Jun 18, 2019
1 parent 08fc3e6 commit 0cc96d2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/resources/non_entities/sessions_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def post(self):
Generates a sessionID if the user has correct credentials
:return: String - SessionID
"""
if request.data == b"": # request.data returns a byte object, it can only be checked for empty like this
return "Unauthorized", 401
if request.json == {"username": "user", "password": "password"}:
if not (request.data and "username" in request.json and "password" in request.json):
return "Bad request", 400
if request.json["username"] == "user" and request.json["password"] == "password":
session_id = str(uuid.uuid1())
insert_row_into_table(SESSION(ID=session_id))
return {"sessionID": session_id}, 201
Expand Down

0 comments on commit 0cc96d2

Please sign in to comment.