solidusio / solidus_auth_devise

🔑 Devise authentication for your Solidus store.
http://solidus.io
BSD 3-Clause "New" or "Revised" License
52 stars 124 forks source link

RuntimeError: Can't modify frozen hash #184

Closed skukx closed 4 years ago

skukx commented 4 years ago

When calling user.really_destroy! the following error raises

RuntimeError: Can't modify frozen hash

This is due to scramble_email_and_password method.

When really destroying the method, this callback attempts to save a record which is deleted.

See: https://github.com/solidusio/solidus_auth_devise/blob/master/app/models/spree/user.rb#L53

Solution:

Place at the top of the method

def scramble_email_and_password
  return if destroyed?

  # Rest of code
end

This way, if we're actually destroying the record. save won't get called.