Skip to content

Conversation

@socksprox
Copy link

Problem

When using the user generation endpoint with both email_prefix and generate_count parameters, only one user was being created instead of the specified count.

For example, this request would only generate 1 user instead of 5:

{
  "email_prefix": "company",
  "email_suffix": "example.com", 
  "password": "password123",
  "expired_at": 1757973600,
  "plan_id": 5,
  "generate_count": 5,
  "download_csv": false
}

Solution

  • Modified the generate() method to properly handle both email_prefix and generate_count parameters
  • Added new multiGenerateWithPrefix() method for bulk user creation with prefixed emails
  • Users are now created with incremented email addresses: [email protected], [email protected], etc.
  • Maintains full backward compatibility for single user generation
  • Includes proper email validation and database transaction handling

Changes Made

  1. Modified generate() method: Added logic to call multiGenerateWithPrefix() when both email_prefix and generate_count are provided
  2. Added multiGenerateWithPrefix() method: New method that generates multiple users with incremented email prefixes
  3. Email validation: Checks that none of the generated email addresses already exist before creating any users
  4. Transaction safety: Uses database transactions for safe batch creation
  5. Feature parity: Supports both JSON response and CSV download functionality

Testing

The fix has been tested with the original failing request and now properly generates 5 users with emails:

Backward Compatibility

✅ Single user generation (no generate_count) continues to work as before
✅ Multiple user generation without email_prefix (random emails) continues to work as before
✅ All existing functionality is preserved

@socksprox
Copy link
Author

@cedar2025 Please check it out, I tested this commit on my developing xboard instance and it worked well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant