I have an existing admin_user that I’m basically migrating to an additional admin_user record, and I want to set the password hash for the new record with the value from the old record.
Because _beforeSave hooks setPassword() and encrypts it, it doesn’t seem possible.
Was in the process of writing this question, when I figured out how to solve it, so I’ll go ahead and post my own answer here, in case it helps anyone else.
Looks like you need to overload the
Mage_Admin_Model_Userclass to do this. Since you’ll probably be loading the class directly and calling the method to set the password, you probably won’t need to worry about rewrites or event observing.Here’s how I did it:
And then, to change it, do the following. In my case, I did this within a custom migration script that I wrote.
The
setPasswordHash()andgetPasswordHash()methods are regular Magento magic getters / setters, so they don’t need to be defined anywhere.UPDATE: Don’t downvote for answering own question, it’s encouraged.