YOLO session_id
parent
738ad622b8
commit
a4562b615a
|
@ -6,11 +6,6 @@ from files.helpers.cloudflare import CLOUDFLARE_AVAILABLE
|
|||
from files.routes.wrappers import *
|
||||
from files.__main__ import app, limiter
|
||||
|
||||
def session_init():
|
||||
if not session.get("session_id"):
|
||||
session.permanent = True
|
||||
session["session_id"] = secrets.token_hex(49)
|
||||
|
||||
@app.before_request
|
||||
def before_request():
|
||||
if request.host != SITE:
|
||||
|
@ -52,7 +47,6 @@ def before_request():
|
|||
request.full_path = request.full_path.rstrip('?').rstrip('/')
|
||||
if not request.full_path: request.full_path = '/'
|
||||
|
||||
session_init()
|
||||
limiter.check()
|
||||
g.db = db_session()
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import time
|
||||
import secrets
|
||||
|
||||
from os import environ, listdir, path
|
||||
|
||||
|
@ -55,6 +56,10 @@ def calc_users():
|
|||
loggedin_chat = cache.get(CHAT_ONLINE_CACHE_KEY) or 0
|
||||
timestamp = int(time.time())
|
||||
|
||||
if not session.get("session_id"):
|
||||
session.permanent = True
|
||||
session["session_id"] = secrets.token_hex(49)
|
||||
|
||||
if v:
|
||||
if session["session_id"] in loggedout: del loggedout[session["session_id"]]
|
||||
loggedin[v.id] = timestamp
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import time
|
||||
import secrets
|
||||
|
||||
from random import randint
|
||||
from typing import Optional, Union, Callable, List
|
||||
|
@ -15,10 +14,6 @@ from files.helpers.security import generate_hash, validate_hash
|
|||
from files.__main__ import cache
|
||||
|
||||
def get_raw_formkey(u:User):
|
||||
if not session.get("session_id"):
|
||||
session.permanent = True
|
||||
session["session_id"] = secrets.token_hex(49)
|
||||
|
||||
return f"{session['session_id']}+{u.id}+{u.login_nonce}"
|
||||
|
||||
def get_formkey(u:Optional[User]):
|
||||
|
|
Loading…
Reference in New Issue