Skip to content

Commit

Permalink
Add csrf checks to support page
Browse files Browse the repository at this point in the history
  • Loading branch information
acasajus committed May 16, 2024
1 parent 07fa66c commit 57bc383
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/dashboard/views/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from app.dashboard.base import dashboard_bp
from app.extensions import limiter
from app.log import LOG
from app.utils import CSRFValidationForm

VALID_MIME_TYPES = ["text/plain", "message/rfc822"]

Expand Down Expand Up @@ -90,7 +91,12 @@ def support_route():
flash("Support isn't enabled", "error")
return redirect(url_for("dashboard.index"))

csrf_form = CSRFValidationForm()

if request.method == "POST":
if not csrf_form.validate():
flash("Invalid request", "warning")
return redirect(url_for("dashboard.setting"))
content = request.form.get("ticket_content")
email = request.form.get("ticket_email")

Expand Down Expand Up @@ -121,4 +127,8 @@ def support_route():
)
return redirect(url_for("dashboard.index"))

return render_template("dashboard/support.html", ticket_email=current_user.email)
return render_template(
"dashboard/support.html",
ticket_email=current_user.email,
csrf_form=csrf_form,
)

0 comments on commit 57bc383

Please sign in to comment.