forked from rDrama/rDrama
WPD migration code
parent
d07a6cbc08
commit
6d538e2cd3
|
@ -85,6 +85,10 @@ def before_request():
|
||||||
with open('/site_settings.json', 'r', encoding='utf_8') as f:
|
with open('/site_settings.json', 'r', encoding='utf_8') as f:
|
||||||
app.config['SETTINGS'] = json.load(f)
|
app.config['SETTINGS'] = json.load(f)
|
||||||
|
|
||||||
|
if request.host == 'watchpeopledie.co' and app.config["SERVER_NAME"] == "watchpeopledie.tv":
|
||||||
|
#### WPD TEMP #### temporary WPD migration logic: redirect to /
|
||||||
|
if request.host != '/':
|
||||||
|
return redirect('/')
|
||||||
if request.host != app.config["SERVER_NAME"]: return {"error": "Unauthorized host provided."}, 403
|
if request.host != app.config["SERVER_NAME"]: return {"error": "Unauthorized host provided."}, 403
|
||||||
if request.headers.get("CF-Worker"): return {"error": "Cloudflare workers are not allowed to access this website."}, 403
|
if request.headers.get("CF-Worker"): return {"error": "Cloudflare workers are not allowed to access this website."}, 403
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,29 @@ from files.helpers.awards import award_timers
|
||||||
@limiter.limit("3/second;30/minute;5000/hour;10000/day")
|
@limiter.limit("3/second;30/minute;5000/hour;10000/day")
|
||||||
@auth_desired_with_logingate
|
@auth_desired_with_logingate
|
||||||
def front_all(v, sub=None, subdomain=None):
|
def front_all(v, sub=None, subdomain=None):
|
||||||
|
#### WPD TEMP #### special front logic
|
||||||
|
from helpers.security import generate_hash, validate_hash
|
||||||
|
from datetime import datetime
|
||||||
|
today = datetime.today()
|
||||||
|
if request.host == 'watchpeopledie.co':
|
||||||
|
if v and not v.admin_level: # security: don't auto login admins
|
||||||
|
hash = generate_hash(f'{v.id}+{today.year}+{today.month}+{today.day}+{today.hour}+WPDusermigration')
|
||||||
|
return redirect(f'/?user={v.id}&code={hash}', 301)
|
||||||
|
else:
|
||||||
|
return render_template('wpdco.html')
|
||||||
|
elif request.host == 'watchpeopledie.tv' and not v: # security: don't try to login people into accounts more than once
|
||||||
|
req_user = request.values.get('user')
|
||||||
|
req_code = request.values.get('code')
|
||||||
|
if req_user and req_code:
|
||||||
|
from routes.login import on_login
|
||||||
|
user = get_account(req_user)
|
||||||
|
if user:
|
||||||
|
if user.admin_level:
|
||||||
|
abort(401)
|
||||||
|
else:
|
||||||
|
if validate_hash(req_code, f'{v.id}+{today.year}+{today.month}+{today.day}+{today.hour}+WPDusermigration'):
|
||||||
|
on_login(user)
|
||||||
|
#### WPD TEMP #### end special front logic
|
||||||
if sub:
|
if sub:
|
||||||
sub = sub.strip().lower()
|
sub = sub.strip().lower()
|
||||||
if sub == 'chudrama' and not (v and v.can_see_chudrama): abort(403)
|
if sub == 'chudrama' and not (v and v.can_see_chudrama): abort(403)
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{% extends "default.html" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
<title>cute cat pictures or something idk</title>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block pagetype %}sadface{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="center">
|
||||||
|
<div class="col-10 col-md-5">
|
||||||
|
<div class="text-center px-3 my-8">
|
||||||
|
hi fish i need some txt thx
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue