lingthio / Flask-User

Customizable User Authorization & User Management: Register, Confirm, Login, Change username/password, Forgot password and more.
http://flask-user.readthedocs.io/
MIT License
1.06k stars 292 forks source link

important: user instance is not equal to itself #318

Open laundmo opened 4 years ago

laundmo commented 4 years ago

comparing any user instance to iteself will return false, which is breaking other extensions like sqlalchemy wtfroms which cannot validate that a user is equal to the user choices.

example code that breaks

a = User.query.first()
if a == a:
    print("everything is good, they are equal")
else:
    print("under no circumstances should python objects not be equal to themselves")

result: "under no circumstances should python objects not be equal to themselves"

apparently the __eq__ override is broken, since it does not use the primary key.

this is in my opinion a issue that will force me to not use flask-user in the future

Chaostheorie commented 3 years ago

flask user is not really maintained since the start of 2020. If you have an application that uses flask_user and you can't replace flask user with flask login I would recommend you to use a custom UserManager with a custom User class.

Though for the user object specifically a simple workaround like a function that compares the attributes should be enough.