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
Currently the user model has a property password and every line that saves a new password has to manually hash it. The method update somewhat encapsulates this already.
A nice way to do this imo, would be to rename the property to _password_digest (making in private) and adding accessors with @property and @setter to password which encapsulate the hashing.
This way a new password can be saved like this:
if user.check_password(old_password):
user.password = new_password
and it will still be hashed. user.update(password=new_password) will also work without overriding the update method then.
The text was updated successfully, but these errors were encountered:
Currently the user model has a property
password
and every line that saves a new password has to manually hash it. The method update somewhat encapsulates this already.A nice way to do this imo, would be to rename the property to
_password_digest
(making in private) and adding accessors with@property
and@setter
to password which encapsulate the hashing.This way a new password can be saved like this:
and it will still be hashed.
user.update(password=new_password)
will also work without overriding theupdate
method then.The text was updated successfully, but these errors were encountered: