forked from MarseyWorld/MarseyWorld
use abort instead of return {"error":
parent
99715c7559
commit
e3529d0495
|
@ -27,9 +27,10 @@ def before_request():
|
||||||
ua = g.agent.lower()
|
ua = g.agent.lower()
|
||||||
|
|
||||||
if request.host != SITE:
|
if request.host != SITE:
|
||||||
return {"error": "Unauthorized host provided"}, 403
|
abort(403, "Unauthorized host provided!")
|
||||||
|
|
||||||
if request.headers.get("CF-Worker"): return {"error": "Cloudflare workers are not allowed to access this website."}, 403
|
if request.headers.get("CF-Worker"):
|
||||||
|
abort(403, "Cloudflare workers are not allowed to access this website.")
|
||||||
|
|
||||||
if not get_setting('bots') and request.headers.get("Authorization"): abort(403)
|
if not get_setting('bots') and request.headers.get("Authorization"): abort(403)
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ def post_id(pid, anything=None, v=None, sub=None):
|
||||||
if not User.can_see(v, post): abort(403)
|
if not User.can_see(v, post): abort(403)
|
||||||
|
|
||||||
if post.over_18 and not (v and v.over_18) and session.get('over_18', 0) < int(time.time()):
|
if post.over_18 and not (v and v.over_18) and session.get('over_18', 0) < int(time.time()):
|
||||||
if g.is_api_or_xhr: return {"error":"Must be 18+ to view"}, 451
|
if g.is_api_or_xhr: abort(451, "Must be 18+ to view")
|
||||||
return render_template("errors/nsfw.html", v=v)
|
return render_template("errors/nsfw.html", v=v)
|
||||||
|
|
||||||
if post.new: defaultsortingcomments = 'new'
|
if post.new: defaultsortingcomments = 'new'
|
||||||
|
|
|
@ -12,7 +12,7 @@ from files.__main__ import app, cache, limiter
|
||||||
@app.post("/exile/post/<pid>")
|
@app.post("/exile/post/<pid>")
|
||||||
@is_not_permabanned
|
@is_not_permabanned
|
||||||
def exile_post(v:User, pid):
|
def exile_post(v:User, pid):
|
||||||
if v.shadowbanned: return {"error": "Internal Server Error"}, 500
|
if v.shadowbanned: abort(500)
|
||||||
p = get_post(pid)
|
p = get_post(pid)
|
||||||
sub = p.sub
|
sub = p.sub
|
||||||
if not sub: abort(400)
|
if not sub: abort(400)
|
||||||
|
@ -43,7 +43,7 @@ def exile_post(v:User, pid):
|
||||||
@app.post("/exile/comment/<cid>")
|
@app.post("/exile/comment/<cid>")
|
||||||
@is_not_permabanned
|
@is_not_permabanned
|
||||||
def exile_comment(v:User, cid):
|
def exile_comment(v:User, cid):
|
||||||
if v.shadowbanned: return {"error": "Internal Server Error"}, 500
|
if v.shadowbanned: abort(500)
|
||||||
c = get_comment(cid)
|
c = get_comment(cid)
|
||||||
sub = c.post.sub
|
sub = c.post.sub
|
||||||
if not sub: abort(400)
|
if not sub: abort(400)
|
||||||
|
@ -327,7 +327,7 @@ def create_sub2(v):
|
||||||
return render_template("sub/create_hole.html", v=v, cost=HOLE_COST, error="You don't have enough coins!"), 403
|
return render_template("sub/create_hole.html", v=v, cost=HOLE_COST, error="You don't have enough coins!"), 403
|
||||||
|
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
if v.shadowbanned: return {"error": "Internal Server Error"}, 500
|
if v.shadowbanned: abort(500)
|
||||||
|
|
||||||
sub = Sub(name=name)
|
sub = Sub(name=name)
|
||||||
g.db.add(sub)
|
g.db.add(sub)
|
||||||
|
@ -348,7 +348,7 @@ def kick(v:User, pid):
|
||||||
|
|
||||||
if not post.sub: abort(403)
|
if not post.sub: abort(403)
|
||||||
if not v.mods(post.sub): abort(403)
|
if not v.mods(post.sub): abort(403)
|
||||||
if v.shadowbanned: return {"error": "Internal Server Error"}, 500
|
if v.shadowbanned: abort(500)
|
||||||
|
|
||||||
old = post.sub
|
old = post.sub
|
||||||
post.sub = None
|
post.sub = None
|
||||||
|
|
Loading…
Reference in New Issue