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