forked from rDrama/rDrama
no more g.timestamp y'all couldn't behave
parent
da27b16c39
commit
162bf9dad7
|
@ -103,8 +103,6 @@ def before_request():
|
||||||
if 'iphone' in ua or 'ipad' in ua or 'ipod' in ua or 'mac os' in ua or ' firefox/' in ua: g.inferior_browser = True
|
if 'iphone' in ua or 'ipad' in ua or 'ipod' in ua or 'mac os' in ua or ' firefox/' in ua: g.inferior_browser = True
|
||||||
else: g.inferior_browser = False
|
else: g.inferior_browser = False
|
||||||
|
|
||||||
g.timestamp = int(time.time())
|
|
||||||
|
|
||||||
|
|
||||||
@app.teardown_appcontext
|
@app.teardown_appcontext
|
||||||
def teardown_request(error):
|
def teardown_request(error):
|
||||||
|
|
|
@ -50,4 +50,4 @@ def timestamp(timestamp):
|
||||||
|
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_constants():
|
def inject_constants():
|
||||||
return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID, "PIZZASHILL_ID":PIZZASHILL_ID, "config":app.config.get, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "ADMIGGERS":ADMIGGERS, "datetime":datetime}
|
return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID, "PIZZASHILL_ID":PIZZASHILL_ID, "config":app.config.get, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "ADMIGGERS":ADMIGGERS, "datetime":datetime, "time":time}
|
|
@ -7,14 +7,17 @@ from random import randint
|
||||||
def get_logged_in_user():
|
def get_logged_in_user():
|
||||||
|
|
||||||
if not session.get("session_id"):
|
if not session.get("session_id"):
|
||||||
|
session.permanent = True
|
||||||
session["session_id"] = secrets.token_hex(49)
|
session["session_id"] = secrets.token_hex(49)
|
||||||
|
|
||||||
|
timestamp = int(time.time())
|
||||||
|
|
||||||
sessions = cache.get(f'{SITE}_sessions') or {}
|
sessions = cache.get(f'{SITE}_sessions') or {}
|
||||||
sessions[session["session_id"]] = g.timestamp
|
sessions[session["session_id"]] = timestamp
|
||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
for val in sessions.values():
|
for val in sessions.values():
|
||||||
if g.timestamp - val < 15*60:
|
if timestamp - val < 15*60:
|
||||||
counter += 1
|
counter += 1
|
||||||
g.counter = counter
|
g.counter = counter
|
||||||
|
|
||||||
|
@ -75,7 +78,6 @@ def auth_desired(f):
|
||||||
def auth_required(f):
|
def auth_required(f):
|
||||||
|
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
g.timestamp = int(time.time())
|
|
||||||
v = get_logged_in_user()
|
v = get_logged_in_user()
|
||||||
if not v: abort(401)
|
if not v: abort(401)
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ def merge(v, id1, id2):
|
||||||
if v.id != AEVANN_ID: abort(403)
|
if v.id != AEVANN_ID: abort(403)
|
||||||
|
|
||||||
if time.time() - session.get('verified', 0) > 3:
|
if time.time() - session.get('verified', 0) > 3:
|
||||||
session.pop("session_id", None)
|
|
||||||
session.pop("lo_user", None)
|
session.pop("lo_user", None)
|
||||||
path = request.path
|
path = request.path
|
||||||
qs = urlencode(dict(request.values))
|
qs = urlencode(dict(request.values))
|
||||||
|
@ -91,7 +90,6 @@ def merge_all(v, id):
|
||||||
if v.id != AEVANN_ID: abort(403)
|
if v.id != AEVANN_ID: abort(403)
|
||||||
|
|
||||||
if time.time() - session.get('verified', 0) > 3:
|
if time.time() - session.get('verified', 0) > 3:
|
||||||
session.pop("session_id", None)
|
|
||||||
session.pop("lo_user", None)
|
session.pop("lo_user", None)
|
||||||
path = request.path
|
path = request.path
|
||||||
qs = urlencode(dict(request.values))
|
qs = urlencode(dict(request.values))
|
||||||
|
|
|
@ -139,8 +139,6 @@ def login_post():
|
||||||
else:
|
else:
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
||||||
session.permanent = True
|
|
||||||
session["session_id"] = token_hex(49)
|
|
||||||
session["lo_user"] = account.id
|
session["lo_user"] = account.id
|
||||||
session["login_nonce"] = account.login_nonce
|
session["login_nonce"] = account.login_nonce
|
||||||
if account.id == AEVANN_ID: session["verified"] = time.time()
|
if account.id == AEVANN_ID: session["verified"] = time.time()
|
||||||
|
@ -173,7 +171,6 @@ def me(v):
|
||||||
@auth_required
|
@auth_required
|
||||||
def logout(v):
|
def logout(v):
|
||||||
|
|
||||||
session.pop("session_id", None)
|
|
||||||
session.pop("lo_user", None)
|
session.pop("lo_user", None)
|
||||||
|
|
||||||
return {"message": "Logout successful!"}
|
return {"message": "Logout successful!"}
|
||||||
|
@ -364,8 +361,6 @@ def sign_up_post(v):
|
||||||
|
|
||||||
send_notification(new_user.id, WELCOME_MSG)
|
send_notification(new_user.id, WELCOME_MSG)
|
||||||
|
|
||||||
session.permanent = True
|
|
||||||
session["session_id"] = token_hex(49)
|
|
||||||
session["lo_user"] = new_user.id
|
session["lo_user"] = new_user.id
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
|
@ -207,7 +207,7 @@
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if request.path == '/' and g.timestamp > session.get('tooltip_last_dismissed',0)+60*60*24*30 and not g.webview %}
|
{% if request.path == '/' and time.time() > session.get('tooltip_last_dismissed',0)+60*60*24*30 and not g.webview %}
|
||||||
<div id="mobile-prompt-container" class="fixed-top">
|
<div id="mobile-prompt-container" class="fixed-top">
|
||||||
<div id="mobile-prompt" href="javascript:void(0)" data-bs-toggle="tooltip" data-bs-container="#mobile-prompt-container" data-bs-placement="top" data-bs-trigger="click" data-bs-original-title="Install the {{SITE_NAME}} webapp by saving this page to your home screen!"></div>
|
<div id="mobile-prompt" href="javascript:void(0)" data-bs-toggle="tooltip" data-bs-container="#mobile-prompt-container" data-bs-placement="top" data-bs-trigger="click" data-bs-original-title="Install the {{SITE_NAME}} webapp by saving this page to your home screen!"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue