Fix user generation with email_prefix to support multiple users #689
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using the user generation endpoint with both
email_prefixandgenerate_countparameters, 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
generate()method to properly handle bothemail_prefixandgenerate_countparametersmultiGenerateWithPrefix()method for bulk user creation with prefixed emails[email protected],[email protected], etc.Changes Made
generate()method: Added logic to callmultiGenerateWithPrefix()when bothemail_prefixandgenerate_countare providedmultiGenerateWithPrefix()method: New method that generates multiple users with incremented email prefixesTesting
The fix has been tested with the original failing request and now properly generates 5 users with emails:
[email protected][email protected][email protected][email protected][email protected]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