small adjustments

master
Aevann1 2022-10-21 17:11:12 +02:00
parent 5ba33396d5
commit 360aa99fe1
3 changed files with 9 additions and 13 deletions

View File

@ -86,12 +86,10 @@ def before_request():
with open('/site_settings.json', 'r', encoding='utf_8') as f:
app.config['SETTINGS'] = json.load(f)
### WPD TEMP ####
if request.host != SITE and SITE != "watchpeopledie.co":
if request.host != SITE:
return {"error": "Unauthorized host provided"}, 403
#### END WPD TEMP ####
# uncomment below after done with WPD migration
# if request.host != SITE: 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 not app.config['SETTINGS']['Bots'] and request.headers.get("Authorization"): abort(403)
@ -101,12 +99,10 @@ def before_request():
g.inferior_browser = 'iphone' in ua or 'ipad' in ua or 'ipod' in ua or 'mac os' in ua or ' firefox/' in ua
#### WPD TEMP #### temporary WPD migration logic: redirect to /
if request.host == 'watchpeopledie.co' and SITE == "watchpeopledie.co":
request.path = request.path.rstrip('/')
if not request.path: request.path = '/'
if request.path != '/':
return redirect('/')
if SITE == "watchpeopledie.co" and request.path != '/':
return redirect('/')
#### END WPD TEMP ####
request.path = request.path.rstrip('/')
if not request.path: request.path = '/'
request.full_path = request.full_path.rstrip('?').rstrip('/')

View File

@ -97,7 +97,7 @@ def auth_desired_with_logingate(f):
if app.config['SETTINGS']['login_required'] and not v: abort(401)
#### WPD TEMP #### disable this /logged_out thing on .co
if request.host == 'watchpeopledie.co':
if SITE == 'watchpeopledie.co':
return make_response(f(*args, v=v, **kwargs))
#### END WPD TEMP ####

View File

@ -21,13 +21,13 @@ def front_all(v, sub=None, subdomain=None):
from files.helpers.security import generate_hash, validate_hash
from datetime import datetime
now = datetime.utcnow()
if request.host == 'watchpeopledie.co':
if SITE == 'watchpeopledie.co':
if v and not v.admin_level and not v.id <= 9: # security: don't auto login admins or bots
hash = generate_hash(f'{v.id}+{now.year}+{now.month}+{now.day}+{now.hour}+WPDusermigration')
return redirect(f'https://watchpeopledie.tv/logged_out?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
elif SITE == '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: