From 2ad1926eed9e676a76dbfc71fefe0eb24636c343 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 21 Jan 2024 21:27:03 +0000 Subject: [PATCH] longer sessions --- backend/app.py | 2 ++ backend/schema.py | 1 + 2 files changed, 3 insertions(+) diff --git a/backend/app.py b/backend/app.py index 379a6cf..00f95f7 100644 --- a/backend/app.py +++ b/backend/app.py @@ -4,6 +4,7 @@ import os from sqlalchemy import create_engine from sqlalchemy.orm import Session +import datetime from . import schema as s @@ -32,6 +33,7 @@ def create_app(test_config=None): DATABASE_ECHO=False, SESSION_COOKIE_SECURE=True, SESSION_COOKIE_SAMESITE="None", + PERMANENT_SESSION_LIFETIME=datetime.timedelta(days=365) ) if test_config is None: # pragma: no cover # load the instance config, if it exists, when not testing diff --git a/backend/schema.py b/backend/schema.py index 47553d7..f1aec0c 100644 --- a/backend/schema.py +++ b/backend/schema.py @@ -383,6 +383,7 @@ def login(self, info: Info, username: str, password: str) -> t.Optional[m.User]: user = by_username(info, username) if not user or not user.check_password(password): raise Exception("User not found") + info.context["cookie"].permanent = True info.context["cookie"]["username"] = user.username return user