Skip to content

Commit

Permalink
Merge pull request #121 from ral-facilities/feature/set-session-info-…
Browse files Browse the repository at this point in the history
…#120

#120 - set username + expiredatetime on POST /session
  • Loading branch information
louise-davies authored May 29, 2020
2 parents 130a736 + 206a78f commit 05ad009
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 Down Expand Up @@ -54,7 +55,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="simple/root", EXPIREDATETIME=datetime.datetime.now() + datetime.timedelta(days=1)))
return {"sessionID": session_id}, 201
return "Forbidden", 403

Expand Down

0 comments on commit 05ad009

Please sign in to comment.