Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't break on empty play key #87

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@


def validate_play_key(form, field):
"""Validates a field for a valid phone number
"""Validates a field for a valid play kyey
Args:
form: REQUIRED, the field's parent form
field: REQUIRED, the field with data
Returns:
None, raises ValidationError if failed
"""
# jank to get the fireign key that we need back into the field
# jank to get the foreign key that we need back into the field
if current_app.config["REQUIRE_PLAY_KEY"]:
field.data = PlayKey.key_is_valid(key_string=field.data)
return
return True

class CustomRecaptcha(Recaptcha):
def __call__(self, form, field):
Expand All @@ -49,10 +49,7 @@ def customize(self, app):
class CustomRegisterForm(RegisterForm):
play_key_id = StringField(
'Play Key',
validators=[
Optional(),
validate_play_key,
]
validators=[validate_play_key]
)
recaptcha = RecaptchaField(
validators=[CustomRecaptcha()]
Expand Down