-
Notifications
You must be signed in to change notification settings - Fork 10
How would you change the User model to allow for a password to be updated? #3
Comments
@davesag I imagine using a |
@davesag Also, I'll apologize for having little activity on this project for awhile. I should be getting back to the article series soon as time permits. |
Here's how I ended up doing it
|
Very nice. Thanks for sharing :)
|
Your
User
model is fine for a very simple case but in the real-world people will need to be able to change their passwords.Given you can't access model methods from within the
beforeCreate
andbeforeSave
methods, and with a view to maintaining DRYness as much as possible, what changes would you make to yourUser
model such that when a user's password is updated it's properly hashed. Obviously just changingbeforeCreate
tobeforeSave
is not going to work as then the password will be rehashed every time it's saved.There are a number of ways to do this but I'm wondering what the best-practice, DRY way would be.
The text was updated successfully, but these errors were encountered: