diff --git a/CTFd/forms/auth.py b/CTFd/forms/auth.py index 74fa3aa2..ead98d5d 100644 --- a/CTFd/forms/auth.py +++ b/CTFd/forms/auth.py @@ -25,7 +25,16 @@ def RegistrationForm(*args, **kwargs): new_fields = UserFields.query.all() for field in new_fields: - setattr(_RegistrationForm, f"fields[{field.id}]", StringField(field.name)) + validators = [] + if field.required: + validators.append(InputRequired()) + setattr( + _RegistrationForm, + f"fields[{field.id}]", + StringField( + field.name, description=field.description, validators=validators + ), + ) return _RegistrationForm(*args, **kwargs) diff --git a/CTFd/forms/self.py b/CTFd/forms/self.py index 6fc590f1..b6d2f405 100644 --- a/CTFd/forms/self.py +++ b/CTFd/forms/self.py @@ -42,7 +42,17 @@ def SettingsForm(*args, **kwargs): new_fields = UserFields.query.filter_by(editable=True).all() for field in new_fields: - setattr(_SettingsForm, f"fields[{field.id}]", StringField(field.name)) + validators = [] + if field.required: + validators.append(InputRequired()) + + setattr( + _SettingsForm, + f"fields[{field.id}]", + StringField( + field.name, description=field.description, validators=validators + ), + ) return _SettingsForm(*args, **kwargs) diff --git a/CTFd/forms/users.py b/CTFd/forms/users.py index 4dfa0c4d..a88f6ca8 100644 --- a/CTFd/forms/users.py +++ b/CTFd/forms/users.py @@ -91,7 +91,17 @@ def UserEditForm(*args, **kwargs): new_fields = UserFields.query.all() for field in new_fields: - setattr(_UserEditForm, f"fields[{field.id}]", StringField(field.name)) + validators = [] + if field.required: + validators.append(InputRequired()) + + setattr( + _UserEditForm, + f"fields[{field.id}]", + StringField( + field.name, description=field.description, validators=validators + ), + ) return _UserEditForm(*args, **kwargs) @@ -113,6 +123,16 @@ def UserCreateForm(*args, **kwargs): new_fields = UserFields.query.all() for field in new_fields: - setattr(_UserCreateForm, f"fields[{field.id}]", StringField(field.name)) + validators = [] + if field.required: + validators.append(InputRequired()) + + setattr( + _UserCreateForm, + f"fields[{field.id}]", + StringField( + field.name, description=field.description, validators=validators + ), + ) return _UserCreateForm(*args, **kwargs) diff --git a/CTFd/themes/admin/templates/modals/users/create.html b/CTFd/themes/admin/templates/modals/users/create.html index 6d848ec0..2c2fa3bf 100644 --- a/CTFd/themes/admin/templates/modals/users/create.html +++ b/CTFd/themes/admin/templates/modals/users/create.html @@ -14,21 +14,32 @@
{{ form.website.label }} + Optional {{ form.website(class="form-control") }}
{{ form.affiliation.label }} + Optional {{ form.affiliation(class="form-control") }}
{{ form.country.label }} + Optional {{ form.country(class="form-control custom-select") }}
{% for k, v in form.extra %}
{{ v.label }} + {% if v.flags.required is false %} + Optional + {% endif %} {{ v(class="form-control") }} + {% if v.description %} + + {{ v.description }} + + {% endif %}
{% endfor %} diff --git a/CTFd/themes/admin/templates/modals/users/edit.html b/CTFd/themes/admin/templates/modals/users/edit.html index 245d39cc..d6512905 100644 --- a/CTFd/themes/admin/templates/modals/users/edit.html +++ b/CTFd/themes/admin/templates/modals/users/edit.html @@ -28,7 +28,15 @@ {% for k, v in form.extra %}
{{ v.label }} + {% if v.flags.required is false %} + Optional + {% endif %} {{ v(class="form-control") }} + {% if v.description %} + + {{ v.description }} + + {% endif %}
{% endfor %} diff --git a/CTFd/themes/core/templates/register.html b/CTFd/themes/core/templates/register.html index 7b51471a..c9c379c0 100644 --- a/CTFd/themes/core/templates/register.html +++ b/CTFd/themes/core/templates/register.html @@ -27,21 +27,38 @@
{{ form.name.label }} {{ form.name(class="form-control", value=name) }} + + Your username on the site +
{{ form.email.label }} {{ form.email(class="form-control", value=email) }} + + Never shown to the public +
{{ form.password.label }} {{ form.password(class="form-control", value=password) }} + + Password used to log into your account +
{{ form.nonce() }} {% for k, v in form.extra %}
{{ v.label }} + {% if v.flags.required is false %} + Optional + {% endif %} {{ v(class="form-control") }} + {% if v.description %} + + {{ v.description }} + + {% endif %}
{% endfor %}