feat: Generate username automatically from first and last name during registration

This commit is contained in:
2026-04-17 23:58:12 +02:00
parent 29e0356641
commit ec165ea6bd
3 changed files with 81 additions and 9 deletions
+27
View File
@@ -57,6 +57,33 @@ def build_name_synonym(first_name, last_name=''):
return combined[:6].title()
def build_username_from_name(first_name, last_name=''):
"""
Build a deterministic username from first and last name.
Format: firstnameLastname (CamelCase, e.g., 'SimonFrings' or 'SFrings')
Ensures uniqueness by allowing server to check existence.
Args:
first_name (str): First name
last_name (str): Last name (optional)
Returns:
str: Generated username
"""
first = _clean_name_fragment(first_name)
last = _clean_name_fragment(last_name)
if first and last:
# Full: FirstLast (e.g., 'SimonFrings')
return (first + last).lower()
elif first:
return first.lower()
elif last:
return last.lower()
else:
return 'user'
ACTION_PERMISSION_KEYS = (
'can_borrow',
'can_insert',