add config for banned users and post prevention

This commit is contained in:
lza_menace 2020-11-22 12:39:21 -08:00
parent 2d4b503f36
commit e4e0ab53ca
2 changed files with 8 additions and 1 deletions

View file

@ -19,3 +19,4 @@ PRAW_USERNAME = 'xxxxxxxx'
PRAW_PASSWORD = 'xxxxxxxx'
SERVER_NAME = 'localhost'
DISCORD_URL = 'xxxxxxx'
BANNED_USERS = {'username': 'reason for the ban'}

View file

@ -4,6 +4,7 @@ from flask import send_from_directory, redirect, url_for, current_app
from werkzeug.utils import secure_filename
from secrets import token_urlsafe
from suchwow import wownero
from suchwow import config
from suchwow.models import Post, Comment
from suchwow.utils.decorators import login_required, profile_required
from suchwow.utils.helpers import allowed_file
@ -54,6 +55,11 @@ def read(id):
@profile_required
def create():
if request.method == "POST":
submitter = session["auth"]["preferred_username"]
if submitter in config.BANNED_USERS:
reason = config.BANNED_USERS[submitter]
flash(f"You can't post for now: {reason}")
return redirect("/")
post_title = request.form.get("title")
# check if the post request has the file part
if "file" not in request.files:
@ -84,7 +90,7 @@ def create():
post = Post(
title=post_title,
text=request.form.get("text", ""),
submitter=session["auth"]["preferred_username"],
submitter=submitter,
image_name=filename,
account_index=account_index,
address_index=0