Ergänzung Datenschutzerklärung und Impressum, Fristenformular in Einstellungen
This commit is contained in:
@@ -60,18 +60,24 @@ def self_registration_enabled(db: Session) -> bool:
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def create_session(db: Session, user: User, response: Response) -> UserSession:
|
||||
# Spät importiert: runtime_settings greift auf get_setting in dieser
|
||||
# Datei zu, ein Import auf Modulebene wäre ein Kreis.
|
||||
from app.runtime_settings import get_duration
|
||||
|
||||
days = get_duration(db, "session_days")
|
||||
|
||||
raw = new_token()
|
||||
csrf = new_token()
|
||||
sess = UserSession(
|
||||
token_hash=hash_token(raw),
|
||||
user_id=user.id,
|
||||
csrf_token=csrf,
|
||||
expires_at=utcnow() + timedelta(days=settings.session_days),
|
||||
expires_at=utcnow() + timedelta(days=days),
|
||||
)
|
||||
db.add(sess)
|
||||
db.flush()
|
||||
|
||||
max_age = settings.session_days * 24 * 3600
|
||||
max_age = days * 24 * 3600
|
||||
# HttpOnly: fuer JavaScript unsichtbar, damit ein XSS-Fund das Token
|
||||
# nicht abgreifen kann.
|
||||
response.set_cookie(
|
||||
|
||||
Reference in New Issue
Block a user