diff options
| -rw-r--r-- | backend/main.py | 10 | ||||
| -rw-r--r-- | frontend/start.js | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/backend/main.py b/backend/main.py index e7cbd84..aaab7a1 100644 --- a/backend/main.py +++ b/backend/main.py @@ -224,20 +224,24 @@ def final_timer_finished(timer_id): machine_status[row[RowIndices.BLOCK] - 1][row[RowIndices.MACHINE] - 1] = Status.FINISHED.name +# sec min hrs days +COOKIE_MAX_AGE = 60 * 60 * 24 * 30 # 30 days + + def create_session(response: fastapi.Response): cookie = secrets.token_hex(32) - response.set_cookie(key="session_key", value=cookie, secure=True) + response.set_cookie(key="session_key", value=cookie, secure=True, max_age=COOKIE_MAX_AGE) return cookie def authenticate_block(response: fastapi.Response, machine_id: str = None, block: int = None): if machine_id: blk = URI_TO_MACHINES[qr_uri[machine_id]][0] - response.set_cookie(key="auth_block", value=blk, secure=True) + response.set_cookie(key="auth_block", value=blk, secure=True, max_age=COOKIE_MAX_AGE) return blk elif block: blk = block - response.set_cookie(key="auth_block", value=blk, secure=True) + response.set_cookie(key="auth_block", value=blk, secure=True, max_age=COOKIE_MAX_AGE) return block else: return "FAIL" diff --git a/frontend/start.js b/frontend/start.js index 9a27370..4f03350 100644 --- a/frontend/start.js +++ b/frontend/start.js @@ -64,9 +64,7 @@ console.log("notbtn") notbtn.addEventListener("click", () => requestPermission()) async function requestPermission() { console.log("Requesting permission..."); - const onesignal_result = await OneSignalDeferred.push(async function(OneSignal) { - OneSignal.Notifications.requestPermission(); - }); + const onesignal_result = await OneSignal.Notifications.requestPermission(); if (onesignal_result) { notif.remove(); startbtn.disabled = false; |
