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
Committing a PasswordType that has been updated by the verify_and_update method because it's using a deprecated scheme doesn't work correctly for me.
After comparing the password with the correct one, the value is actually updated with the new scheme but when I commit my object, the change isn't reflected to the DB.
Here's a minimal code to reproduce the behavior (using Python 3.3.2):
fromsqlalchemyimportcreate_engine, Column, Integer, eventfromsqlalchemy.ormimportsessionmaker, mapperfromsqlalchemy.ext.declarativeimportdeclarative_basefrompasslib.hashimportmd5_cryptfromsqlalchemy_utilsimportPassword, PasswordType, coercion_listenersql_engine=create_engine('sqlite:///testdb.sqlite')
Session=sessionmaker(bind=sql_engine)
session=Session()
Base=declarative_base()
event.listen(mapper, 'mapper_configured', coercion_listener)
classUser(Base):
__tablename__='users'id=Column(Integer, primary_key=True)
password=Column(PasswordType(
schemes=[
'pbkdf2_sha512',
'md5_crypt'
],
deprecated=['md5_crypt']
))
Base.metadata.drop_all(sql_engine)
Base.metadata.create_all(sql_engine)
user=User()
session.add(user)
user.password=Password(md5_crypt.encrypt('b').encode('utf-8'))
session.commit()
print(user.password.hash) # The md5 hashprint(user.password=='b') # True and update the hashprint(user.password.hash) # The hash is now pbkdf2_sha512session.commit() # Nothing changesuser=session.query(User).get(1) # Get the previous object from the databaseprint(user.password.hash) # The password is still a md5 hash instead of pbkdf2_sha512
Is this the correct behavior or am I missing something ?
The text was updated successfully, but these errors were encountered:
Committing a PasswordType that has been updated by the verify_and_update method because it's using a deprecated scheme doesn't work correctly for me.
After comparing the password with the correct one, the value is actually updated with the new scheme but when I commit my object, the change isn't reflected to the DB.
Here's a minimal code to reproduce the behavior (using Python 3.3.2):
Is this the correct behavior or am I missing something ?
The text was updated successfully, but these errors were encountered: