Skip to content

Commit

Permalink
#120 - set username + expiredatetime on POST /session
Browse files Browse the repository at this point in the history
  • Loading branch information
louise-davies committed Feb 6, 2020
1 parent 274c0c1 commit f7f9b74
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/resources/non_entities/sessions_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from common.database_helpers import insert_row_into_table, delete_row_by_id, get_row_by_id
from common.helpers import get_session_id_from_auth_header, requires_session_id, queries_records
from common.models.db_models import SESSION
import datetime


class Sessions(Resource):
Expand All @@ -19,7 +20,7 @@ def post(self):
return "Bad request", 400
if request.json["username"] == "user" and request.json["password"] == "password":
session_id = str(uuid.uuid1())
insert_row_into_table(SESSION, SESSION(ID=session_id))
insert_row_into_table(SESSION, SESSION(ID=session_id, USERNAME="datagateway-api/user", EXPIREDATETIME=datetime.datetime.now() + datetime.timedelta(days=1)))
return {"sessionID": session_id}, 201
return "Forbidden", 403

Expand Down

0 comments on commit f7f9b74

Please sign in to comment.