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
Extending from the pattern that allows developers to simply set the password property and a setter hashes it on the way in. The User model class has substantial documentation on this. The general approach is to declare the property as:
The Building Custom Comparator guide outlines how we can override the comparator of hybrid_property in SQLAlchemy, if we adopt this paradigm then we can achieve comparing password as:
user.password==password
as opposed using check_password method
The text was updated successfully, but these errors were encountered:
SQLAlchemy has custom comparators for hybrid methods but they are for in use with the ORM queries
from prestans days it's a lot more work if you wish to implement a __eq__ override on the object level and would seem to be an overkill given this will be called in very few spots
SQLAlchemy events on the attribute allow us to hash the password when it's set so we are sort of half way there
Found this blog post which is going down the same route as what we want to. Important to note that the blog post is SQLAlchemy 1.4 but there are still valid points in there.
Turns out that we have to look at TypeDecorator, study this and implement a solution
the commit remvoes the event that encrypted the password and uses a custom sqlalchemy
type to achieve the same result, in theory we should be able to use
on the TypeDecorator to compare values and thus achieve what we set out to
the experiments performed so far don't seem to be able to use compare_values as intended
Extending from the pattern that allows developers to simply set the
password
property and a setter hashes it on the way in. TheUser
model class has substantial documentation on this. The general approach is to declare the property as:followed by exposing the
password
property as:and finally overriding the setter to
hash
the password on the way in:The Building Custom Comparator guide outlines how we can override the comparator of
hybrid_property
inSQLAlchemy
, if we adopt this paradigm then we can achieve comparing password as:as opposed using
check_password
methodThe text was updated successfully, but these errors were encountered: