Skip to content

Commit

Permalink
fix: update username regex
Browse files Browse the repository at this point in the history
  • Loading branch information
phette23 committed Jan 29, 2025
1 parent 5581659 commit bf5ae32
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions taxos/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

import yaml

# See our `ACCOUNTS_USERNAME_REGEX` in invenio.cfg
# https://github.com/cca/cca_invenio/blob/main/invenio.cfg
USERNAME_REGEX: re.Pattern = re.compile(r"[a-z][a-z0-9_\.-]{0,23}")


def convert_to_vocabs(
people: list[dict[str, str]]
Expand All @@ -40,9 +44,7 @@ def convert_to_vocabs(
if not email or not email.endswith("@cca.edu"):
continue

# See our `ACCOUNTS_USERNAME_REGEX` in invenio.cfg
# https://github.com/cca/cca_invenio/blob/main/invenio.cfg
if re.search(r"[a-z0-9_\.-]+", p["username"]) is None:
if not USERNAME_REGEX.match(p["username"]):
print(f"Invalid username: {p['username']}")
continue

Expand Down

0 comments on commit bf5ae32

Please sign in to comment.