diff --git a/app/routes/auth.py b/app/routes/auth.py index 274f677..611cd2c 100644 --- a/app/routes/auth.py +++ b/app/routes/auth.py @@ -187,9 +187,6 @@ def register(): if current_user.is_authenticated: return redirect(url_for('main.dashboard')) - # Generate CAPTCHA for GET requests - captcha = generate_captcha() - if request.method == 'POST': # Validate CAPTCHA first captcha_answer = request.form.get('captcha_answer', '') @@ -203,9 +200,12 @@ def register(): ) # Validate input with marshmallow schema + # Convert MultiDict to dict with proper lists for checkbox fields + form_data = dict(request.form) + form_data['games'] = request.form.getlist('games') register_schema = RegisterSchema() try: - validated = register_schema.load(request.form) + validated = register_schema.load(form_data) except ValidationError as err: for field, messages in err.messages.items(): for msg in messages: @@ -223,9 +223,7 @@ def register(): full_name = validated['full_name'] phone = validated.get('phone') selected_games = validated.get('games', []) - trn_username = request.form.get('trn_username', '').strip() or None discord_username = validated.get('discord_username') - league_os_profile = validated.get('league_os_profile') if User.query.filter_by(username=username).first(): flash('Username already exists.', 'danger') @@ -255,14 +253,29 @@ def register(): phone=phone, games=','.join(selected_games) if selected_games else None, discord_username=discord_username, - league_os_profile=league_os_profile, ) db.session.add(user) db.session.commit() + # Create UserGamertag records for each selected game + from app.models import UserGamertag + for game in selected_games: + field_name = f'gamertag_{game}' + gamertag_value = request.form.get(field_name, '').strip() + if gamertag_value: + gamertag = UserGamertag( + user_id=user.id, + game=game, + gamertag=gamertag_value, + ) + db.session.add(gamertag) + db.session.commit() + flash('Your account has been created! You can now log in.', 'success') return redirect(url_for('auth.login')) + # Generate CAPTCHA only for GET requests + captcha = generate_captcha() return render_template('pages/register.html', esport_games=ESPORT_GAMES, captcha=captcha) diff --git a/app/templates/pages/register.html b/app/templates/pages/register.html index 698c2bb..80ccd24 100644 --- a/app/templates/pages/register.html +++ b/app/templates/pages/register.html @@ -1,7 +1,7 @@ {% extends "layouts/base.html" %} {% block title %}Register - TryoutPro{% endblock %} {% block auth_content %} -
+
@@ -22,34 +22,30 @@

E-Sports Profile

-

Set up your competitive gaming profile for tryouts.

+

Select the games you play and provide your gamertag for each.

-
+
-
- {% for game in esport_games %} + {% for game in esport_games %} +
- {% endfor %} +
- Select all games you're signing in for. -
-
- - - Your public Tracker Network profile name. Others can click it to view your stats. + {% endfor %} + Check each game you play, then enter your gamertag for that game.
+
-
- - - Connect your League OS profile for organized play. -

@@ -60,7 +56,69 @@
+ +
+ + +
+ +{% endblock %} + +{% block scripts %} + {% endblock %} \ No newline at end of file diff --git a/app/validators.py b/app/validators.py index 4215442..b6a7c4f 100644 --- a/app/validators.py +++ b/app/validators.py @@ -208,15 +208,6 @@ class RegisterSchema(StripMixin): allow_none=True, load_default=None, ) - trn_username = fields.String( - allow_none=True, - load_default=None, - ) - league_os_profile = fields.String( - validate=validate.Length(max=256), - allow_none=True, - load_default=None, - ) @validates_schema def validate_password_match(self, data, **kwargs):