Skip to content

Commit

Permalink
Merge pull request #520 from christophmeissner/feature/494-restrict-u…
Browse files Browse the repository at this point in the history
…sernames

Restrict new usernames
  • Loading branch information
christophmeissner authored Mar 29, 2022
2 parents f33022f + 6534257 commit 9811b20
Show file tree
Hide file tree
Showing 34 changed files with 610 additions and 64 deletions.
32 changes: 32 additions & 0 deletions accounts/forms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
from django import forms
from django.core.validators import RegexValidator
from django.utils.text import gettext_lazy as _

from registration.forms import RegistrationFormUniqueEmail

username_validator = RegexValidator(
r"[^\w.]",
_('Invalid username. Allowed characters are letters, numbers, "." and "_".'),
inverse_match=True,
)
username_first_char_validator = RegexValidator(
r"^[\d_.]", _("Username must start with a letter."), inverse_match=True
)
username_last_char_validator = RegexValidator(
r"[\w]$", _('Username must end with a letter, a number or "_".')
)
no_consequtive = RegexValidator(
r"[_.]{2,}",
_("Username must not contain consecutive . or _ characters."),
inverse_match=True,
)


class RegistrationForm(RegistrationFormUniqueEmail):

username = forms.CharField(
max_length=32,
min_length=3,
strip=False,
validators=[
username_validator,
username_first_char_validator,
username_last_char_validator,
no_consequtive,
],
)

accept_privacy_policy = forms.BooleanField(
required=True, initial=False, label=_("Accept privacy policy")
)
14 changes: 13 additions & 1 deletion locale/ar/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2022-03-15 17:56+0000\n"
"Last-Translator: Christoph Meißner\n"
"Language-Team: Arabic (http://www.transifex.com/coders4help/volunteer-planner/language/ar/)\n"
Expand Down Expand Up @@ -36,6 +36,18 @@ msgstr ""
msgid "Accounts"
msgstr "الحسابات "

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr ""

Expand Down
14 changes: 13 additions & 1 deletion locale/bg/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2022-03-15 17:56+0000\n"
"Last-Translator: Christoph Meißner\n"
"Language-Team: Bulgarian (http://www.transifex.com/coders4help/volunteer-planner/language/bg/)\n"
Expand Down Expand Up @@ -32,6 +32,18 @@ msgstr ""
msgid "Accounts"
msgstr ""

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr ""

Expand Down
14 changes: 13 additions & 1 deletion locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2022-03-15 17:56+0000\n"
"Last-Translator: Christoph Meißner\n"
"Language-Team: Czech (http://www.transifex.com/coders4help/volunteer-planner/language/cs/)\n"
Expand Down Expand Up @@ -34,6 +34,18 @@ msgstr "poslední přihlášení"
msgid "Accounts"
msgstr "Účty"

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr "Přijmout zásady ochrany osobních údajů"

Expand Down
14 changes: 13 additions & 1 deletion locale/da/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2017-09-22 15:35+0000\n"
"Last-Translator: Dorian Cantzen <[email protected]>\n"
"Language-Team: Danish (http://www.transifex.com/coders4help/volunteer-planner/language/da/)\n"
Expand Down Expand Up @@ -33,6 +33,18 @@ msgstr ""
msgid "Accounts"
msgstr ""

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr ""

Expand Down
14 changes: 13 additions & 1 deletion locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2016-11-21 18:24+0000\n"
"Last-Translator: Sönke Klinger <[email protected]>\n"
"Language-Team: German (http://www.transifex.com/coders4help/volunteer-planner/language/de/)\n"
Expand Down Expand Up @@ -47,6 +47,18 @@ msgstr "Letzte Anmeldung"
msgid "Accounts"
msgstr "Benutzerkonten"

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr "Ungültiger Benutzername. Erlaubte Zeichen sind Buchstaben, Ziffern, \".\" and \".\"."

msgid "Username must start with a letter."
msgstr "Benutzername muss mit einem Buchstaben anfangen."

msgid "Username must end with a letter, a number or \"_\"."
msgstr "Benutzername muss mit einem Buchstaben, einer Ziffer oder \"_\" enden."

msgid "Username must not contain consecutive . or _ characters."
msgstr "Benutzername darf keine aufeinanderfolgenden . oder _ enthalten."

msgid "Accept privacy policy"
msgstr "Einwilligung (nach Art 6 Abs 1 Satz 1 a DSGVO)"

Expand Down
14 changes: 13 additions & 1 deletion locale/el/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2016-01-29 08:23+0000\n"
"Last-Translator: Dorian Cantzen <[email protected]>\n"
"Language-Team: Greek (http://www.transifex.com/coders4help/volunteer-planner/language/el/)\n"
Expand Down Expand Up @@ -37,6 +37,18 @@ msgstr ""
msgid "Accounts"
msgstr "Λογαριασμοί"

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr ""

Expand Down
14 changes: 13 additions & 1 deletion locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2015-10-04 21:53+0000\n"
"Last-Translator: Dorian Cantzen <[email protected]>\n"
"Language-Team: English (http://www.transifex.com/coders4help/volunteer-planner/language/en/)\n"
Expand All @@ -29,6 +29,18 @@ msgstr ""
msgid "Accounts"
msgstr ""

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr ""

Expand Down
14 changes: 13 additions & 1 deletion locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2016-04-13 17:27+0000\n"
"Last-Translator: Antonio Mireles <[email protected]>\n"
"Language-Team: Spanish (http://www.transifex.com/coders4help/volunteer-planner/language/es/)\n"
Expand Down Expand Up @@ -36,6 +36,18 @@ msgstr ""
msgid "Accounts"
msgstr "Cuentas"

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr ""

Expand Down
14 changes: 13 additions & 1 deletion locale/es_MX/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2015-09-24 12:23+0000\n"
"Last-Translator: Dorian Cantzen <[email protected]>\n"
"Language-Team: Spanish (Mexico) (http://www.transifex.com/coders4help/volunteer-planner/language/es_MX/)\n"
Expand Down Expand Up @@ -32,6 +32,18 @@ msgstr ""
msgid "Accounts"
msgstr ""

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr ""

Expand Down
14 changes: 13 additions & 1 deletion locale/fa/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2016-01-29 08:23+0000\n"
"Last-Translator: Dorian Cantzen <[email protected]>\n"
"Language-Team: Persian (http://www.transifex.com/coders4help/volunteer-planner/language/fa/)\n"
Expand Down Expand Up @@ -32,6 +32,18 @@ msgstr ""
msgid "Accounts"
msgstr ""

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr ""

Expand Down
14 changes: 13 additions & 1 deletion locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2016-12-08 20:50+0000\n"
"Last-Translator: Dolfeus <[email protected]>\n"
"Language-Team: French (http://www.transifex.com/coders4help/volunteer-planner/language/fr/)\n"
Expand Down Expand Up @@ -38,6 +38,18 @@ msgstr ""
msgid "Accounts"
msgstr "Comptes utilisateur"

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr ""

Expand Down
14 changes: 13 additions & 1 deletion locale/hr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"POT-Creation-Date: 2022-03-28 17:29+0200\n"
"PO-Revision-Date: 2016-01-29 08:23+0000\n"
"Last-Translator: Dorian Cantzen <[email protected]>\n"
"Language-Team: Croatian (http://www.transifex.com/coders4help/volunteer-planner/language/hr/)\n"
Expand Down Expand Up @@ -32,6 +32,18 @@ msgstr ""
msgid "Accounts"
msgstr ""

msgid "Invalid username. Allowed characters are letters, numbers, \".\" and \"_\"."
msgstr ""

msgid "Username must start with a letter."
msgstr ""

msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgstr ""

msgid "Accept privacy policy"
msgstr ""

Expand Down
Loading

0 comments on commit 9811b20

Please sign in to comment.