diff --git a/app/routes.py b/app/routes.py
index 7581563..0277876 100644
--- a/app/routes.py
+++ b/app/routes.py
@@ -3,6 +3,7 @@ from flask_mail import Message
from itsdangerous import URLSafeTimedSerializer, SignatureExpired, BadSignature
from app.extensions import db, mail, limiter
from app.models import Participant
+import traceback
bp = Blueprint('main', __name__)
@@ -88,16 +89,16 @@ def index():
def verify_email(token):
s = URLSafeTimedSerializer(current_app.config['SECRET_KEY'])
try:
- email = s.loads(token, salt='email-confirm-h4tum-ctf-2025', max_age=3600)
+ email = s.loads(token, salt='email-confirm-h4tum-ctf-2025', max_age=28800)
except SignatureExpired:
- return '
Token expired. Please register again.
'
+ return render_template("error.html", error_message="Token expired. Please register again.")
except BadSignature:
- return 'Invalid token.
'
+ return render_template("error.html", error_message="Invalid token.")
user = Participant.query.filter_by(email=email).first_or_404()
if get_confirmed_count() >= current_app.config['MAX_SPOTS']:
- return 'Sorry! The event filled up while you were verifying.
'
+ return render_template("error.html", error_message="Sorry! The event filled up while you were verifying.")
user.confirmed = True
db.session.commit()
@@ -106,7 +107,7 @@ def verify_email(token):
discord_token = user.discord_token
msg = "You are confirmed!"
if user.looking_for_team:
- msg += " Since you need a team, please join the #looking-for-group channel."
+ msg += " Since you need a team, please join the #team-search channel."
return render_template('success.html', message=msg, discord_link=discord_link, discord_token=discord_token)
@@ -124,3 +125,17 @@ def impressum():
@limiter.exempt
def rules():
return render_template('rules.html')
+
+@bp.errorhandler(429)
+def ratelimit_handler(e):
+ return render_template("ratelimit_error.html", error_message=e.description)
+
+@bp.errorhandler(500)
+def server_error(e):
+ msg = Message('500 Error on registration Website', recipients=["simon.bussmann@tum.de"])
+ full_traceback = traceback.format_exc()
+
+ msg.body = f"An error occurred during registration:\n\n{full_traceback}"
+ mail.send(msg)
+
+ return render_template("error.html", error_message="Internal Server Error. Admin has been notified!")
diff --git a/app/templates/error.html b/app/templates/error.html
new file mode 100644
index 0000000..7b5503a
--- /dev/null
+++ b/app/templates/error.html
@@ -0,0 +1,15 @@
+{% extends "base.html" %}
+{% block content %}
+
+
+
+
+
> Error:
+ {{ error_message }}
+
+
+{% endblock %}
diff --git a/app/templates/ratelimit_error.html b/app/templates/ratelimit_error.html
new file mode 100644
index 0000000..70cfb38
--- /dev/null
+++ b/app/templates/ratelimit_error.html
@@ -0,0 +1,14 @@
+{% extends "base.html" %}
+{% block content %}
+
+
+
+
> Ratelimit exceeded:
+ {{ error_message }}
+
+
+{% endblock %}