Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent store credits authorization_code duplicates with UUID #4041

Closed
spaghetticode opened this issue Apr 29, 2021 · 0 comments · Fixed by #4060
Closed

Prevent store credits authorization_code duplicates with UUID #4041

spaghetticode opened this issue Apr 29, 2021 · 0 comments · Fixed by #4060
Assignees

Comments

@spaghetticode
Copy link
Member

The current implementation of Spree::StoreCredit#generate_authorization_code may generate duplicates since the code is composed of a timestamp string. While in normal operations this is probably never the case, still it's potentially possible, i.e. when creating records concurrently in batches. One easy way to see the problem in action is with Timecop.freeze.

I think that replacing the timestamp component with a UUID or adding the UUID to the current implementation without removing the timestamp would be a more robust solution. Since Ruby standard library includes securerandom, adding SecureRandom.uuid would cause no meaningful overhead to applications.

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 a pull request may close this issue.

1 participant