From 7d39cdb520df740ec6ae132a476f6e58112053dd Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 20 Sep 2022 02:51:01 +0200 Subject: [PATCH 1/5] minor auth_desired refactor --- files/helpers/wrappers.py | 8 ++++++++ files/routes/comments.py | 3 --- files/routes/front.py | 8 -------- files/routes/posts.py | 3 --- files/routes/static.py | 26 +++++--------------------- files/routes/subs.py | 1 + files/routes/users.py | 12 ------------ 7 files changed, 14 insertions(+), 47 deletions(-) diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index 683cf8ca79..8d9c32028d 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -112,6 +112,14 @@ def auth_desired_with_logingate(f): v = get_logged_in_user() if app.config['SETTINGS']['login_required'] and not v: abort(401) + if not v and not request.path.startswith('/logged_out'): + return redirect(f"/logged_out{request.full_path}") + + if v and request.path.startswith('/logged_out'): + redir = request.full_path.replace('/logged_out','') + if not redir: redir = '/' + return redirect(redir) + check_ban_evade(v) return make_response(f(*args, v=v, **kwargs)) diff --git a/files/routes/comments.py b/files/routes/comments.py index b1e08fda49..7d3c44bb95 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -34,9 +34,6 @@ WORDLE_COLOR_MAPPINGS = {-1: "🟥", 0: "🟨", 1: "🟩"} @auth_desired_with_logingate def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None): - if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}#context") - if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out','') + '#context') - try: cid = int(cid) except: abort(404) diff --git a/files/routes/front.py b/files/routes/front.py index 9c9257e11c..fc22ce3fa5 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -19,14 +19,6 @@ from files.helpers.awards import award_timers @auth_desired_with_logingate def front_all(v, sub=None, subdomain=None): - if not v and not request.path.startswith('/logged_out'): - return redirect(f"/logged_out{request.full_path}") - - if v and request.path.startswith('/logged_out'): - redir = request.full_path.replace('/logged_out','') - if not redir.startswith('/'): redir = f'/{redir}' - return redirect(redir) - if sub: sub = sub.strip().lower() if sub == 'chudrama' and not (v and v.can_see_chudrama): abort(403) diff --git a/files/routes/posts.py b/files/routes/posts.py index 1ffa539434..d0bf7da53a 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -106,9 +106,6 @@ def submit_get(v, sub=None): @auth_desired_with_logingate def post_id(pid, anything=None, v=None, sub=None): - if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}") - if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out','')) - try: pid = int(pid) except Exception as e: pass diff --git a/files/routes/static.py b/files/routes/static.py index be78b20935..2bcd6bc61f 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -71,11 +71,8 @@ def marsey_list(): @app.get('/sidebar') @app.get('/logged_out/rules') @app.get('/logged_out/sidebar') -@auth_desired +@auth_desired_with_logingate def sidebar(v): - if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}") - if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out','')) - return render_template('sidebar.html', v=v) @@ -184,7 +181,8 @@ def log_item(id, v): return render_template("log.html", v=v, actions=[action], next_exists=False, page=1, action=action, admins=admins, types=types) @app.get("/directory") -@auth_desired +@app.get("/logged_out/directory") +@auth_desired_with_logingate def static_megathread_index(v): return render_template("megathread_index.html", v=v) @@ -425,26 +423,12 @@ def transfers(v): else: return render_template("transfers.html", v=v, page=page, comments=comments, standalone=True, next_exists=next_exists) -@app.get("/kb/") -@auth_desired -def knowledgebase(v, page): - if not knowledgebase_page_regex.fullmatch(page): - abort(404) - - template_path = f'kb/{SITE_NAME}/{page}.html' - if not os.path.exists('files/templates/' + template_path): - abort(404) - - return render_template(template_path, v=v) - if not os.path.exists(f'files/templates/donate_{SITE_NAME}.html'): copyfile(f'files/templates/donate_rDrama.html', f'files/templates/donate_{SITE_NAME}.html') @app.get('/donate') -@auth_desired +@app.get("/logged_out/donate") +@auth_desired_with_logingate def donate(v): - if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}") - if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out','')) - return render_template(f'donate_{SITE_NAME}.html', v=v) \ No newline at end of file diff --git a/files/routes/subs.py b/files/routes/subs.py index 1d906ab9ed..a86a548315 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -501,6 +501,7 @@ def sub_marsey(v, sub): return redirect(f'/h/{sub}/settings') @app.get("/holes") +@app.get("/logged_out/holes") @auth_desired_with_logingate def subs(v): subs = g.db.query(Sub, func.count(Submission.sub)).outerjoin(Submission, Sub.name == Submission.sub).group_by(Sub.name).order_by(func.count(Submission.sub).desc()).all() diff --git a/files/routes/users.py b/files/routes/users.py index 43d03f5041..ecf524c10f 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -935,12 +935,6 @@ def visitors(v): @auth_desired_with_logingate def u_username(username, v=None): - if not v and not request.path.startswith('/logged_out'): - return redirect(f"/logged_out{request.full_path}") - - if v and request.path.startswith('/logged_out'): - return redirect(request.full_path.replace('/logged_out','')) - u = get_user(username, v=v, rendered=True) if v and username == v.username: @@ -1042,12 +1036,6 @@ def u_username(username, v=None): @auth_desired_with_logingate def u_username_comments(username, v=None): - if not v and not request.path.startswith('/logged_out'): - return redirect(f"/logged_out{request.full_path}") - - if v and request.path.startswith('/logged_out'): - return redirect(request.full_path.replace('/logged_out','')) - user = get_user(username, v=v, rendered=True) if v and username == v.username: From 4560b12835ae1eb5a849da1cccd7f646c8288c37 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 20 Sep 2022 02:51:51 +0200 Subject: [PATCH 2/5] delete gay snappy quote --- snappy_rDrama.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/snappy_rDrama.txt b/snappy_rDrama.txt index 7b12aaedcd..c49a78d581 100644 --- a/snappy_rDrama.txt +++ b/snappy_rDrama.txt @@ -2989,8 +2989,6 @@ it's cool if it's not your thing, but don't yuck someone else's yum :) {[para]} https://rdrama.net/videos/16624761306946733.mp4 {[para]} -@joebiden @soren @duck -{[para]} TRANS LIVES MATTER {[para]} ![](/images/16628662340977426.webp) From 61c586d7cc2441af4150d657bda540be47d5f563 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 20 Sep 2022 02:54:10 +0200 Subject: [PATCH 3/5] make 3 routes auth_required instead of auth_desired --- files/routes/static.py | 6 ++---- files/routes/subs.py | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/files/routes/static.py b/files/routes/static.py index 2bcd6bc61f..e4d5ebe901 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -181,8 +181,7 @@ def log_item(id, v): return render_template("log.html", v=v, actions=[action], next_exists=False, page=1, action=action, admins=admins, types=types) @app.get("/directory") -@app.get("/logged_out/directory") -@auth_desired_with_logingate +@auth_required def static_megathread_index(v): return render_template("megathread_index.html", v=v) @@ -428,7 +427,6 @@ if not os.path.exists(f'files/templates/donate_{SITE_NAME}.html'): copyfile(f'files/templates/donate_rDrama.html', f'files/templates/donate_{SITE_NAME}.html') @app.get('/donate') -@app.get("/logged_out/donate") -@auth_desired_with_logingate +@auth_required def donate(v): return render_template(f'donate_{SITE_NAME}.html', v=v) \ No newline at end of file diff --git a/files/routes/subs.py b/files/routes/subs.py index a86a548315..1893616c5a 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -501,8 +501,7 @@ def sub_marsey(v, sub): return redirect(f'/h/{sub}/settings') @app.get("/holes") -@app.get("/logged_out/holes") -@auth_desired_with_logingate +@auth_required def subs(v): subs = g.db.query(Sub, func.count(Submission.sub)).outerjoin(Submission, Sub.name == Submission.sub).group_by(Sub.name).order_by(func.count(Submission.sub).desc()).all() return render_template('sub/subs.html', v=v, subs=subs) From d206057535c1c2118dde0744d490e6e45d7a9e03 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 20 Sep 2022 02:55:25 +0200 Subject: [PATCH 4/5] change owoify's hat --- files/helpers/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/helpers/const.py b/files/helpers/const.py index 57aa6144d3..e5a991b5b0 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -1077,7 +1077,7 @@ forced_hats = { "marseyawarded": ("Three Lil Marseys", ":marseynotes: :marseynotes: :I prefer to speak in cats:"), "bite": ("Vampire Mask", "When other little girls wanted to be ballet dancers I kind of wanted to be a vampire."), "rainbow": ("Globohomo", "Homosexuality is no longer optional!"), - "owoify": ("Furry Marsey", "Nuzzles, pounces on you, UwU, you're so warm!.."), + "owoify": ("Cat Ears (wiggly)", "Nuzzles, pounces on you, UwU, you're so warm!.."), "earlylife": ("The Merchant", "SHUT IT DOWN, the goys know!"), "marsify": ("Marsified", "I can't pick my own Marseys, help!"), "is_banned": ("Behind Bars", "This user is banned and needs to do better!"), From 9241779c0614dbe32cce50d61a3852293c2065d2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 20 Sep 2022 04:02:48 +0200 Subject: [PATCH 5/5] add border to expanded image --- files/templates/expanded_image_modal.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/templates/expanded_image_modal.html b/files/templates/expanded_image_modal.html index 65b6d1d73e..1a57f0e40c 100644 --- a/files/templates/expanded_image_modal.html +++ b/files/templates/expanded_image_modal.html @@ -6,7 +6,7 @@
- expanded image + expanded image