You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 withTimecop.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
, addingSecureRandom.uuid
would cause no meaningful overhead to applications.The text was updated successfully, but these errors were encountered: