mirror of
https://github.com/quay/quay.git
synced 2025-11-19 10:22:20 +03:00
Fix ldap user login (#509)
* Fix typo * Make sure python-ldap uses str instead of bytes
This commit is contained in:
committed by
GitHub
parent
12941b540d
commit
71a2ba052c
@@ -68,6 +68,14 @@ def _gen_filler_chars(num_filler_chars):
|
||||
|
||||
|
||||
def generate_valid_usernames(input_username):
|
||||
if isinstance(input_username, bytes):
|
||||
try:
|
||||
input_username = input_username.decode("utf-8")
|
||||
except UnicodeDecodeError as ude:
|
||||
raise UnicodeDecodeError(
|
||||
"Username %s contains invalid characters: %s", input_username, ude
|
||||
)
|
||||
|
||||
normalized = unidecode(input_username).strip().lower()
|
||||
prefix = re.sub(INVALID_USERNAME_CHARACTERS, "_", normalized)[:MAX_USERNAME_LENGTH]
|
||||
prefix = re.sub(r"_{2,}", "_", prefix)
|
||||
|
||||
Reference in New Issue
Block a user