From bd3bdda1a67e5df149bd7d6be2d99f8e9b5466bc Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Thu, 21 Nov 2013 05:14:02 -0800 Subject: [PATCH] Ensure this fix works without the coercion listener. --- sqlalchemy_utils/types/password.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sqlalchemy_utils/types/password.py b/sqlalchemy_utils/types/password.py index 3b097b9..bd589ab 100644 --- a/sqlalchemy_utils/types/password.py +++ b/sqlalchemy_utils/types/password.py @@ -166,6 +166,10 @@ class PasswordType(types.TypeDecorator, ScalarCoercible): def process_bind_param(self, value, dialect): if isinstance(value, Password): + # If were given a password secret; encrypt it. + if value.secret is not None: + return self.context.encrypt(value.secret).encode('utf8') + # Value has already been hashed. return value.hash