Closed adamspd closed 6 months ago
Describe the bug The username used is generated even if one is provided by the client
Faulty code
def create_user_with_username(client_data: dict): CLIENT_MODEL = get_user_model() username = generate_unique_username_from_email(client_data['email']) user_data = { 'username': username, 'email': client_data['email'], 'first_name': client_data.get('first_name', ''), 'last_name': client_data.get('last_name', '') } user = CLIENT_MODEL.objects.create_user(**user_data) return user
Solution username = generate_unique_username_from_email(client_data['email']) if 'username' not in client_data else \ client_data['username']
Describe the bug The username used is generated even if one is provided by the client
Faulty code
Solution username = generate_unique_username_from_email(client_data['email']) if 'username' not in client_data else \ client_data['username']