From 7884d637c50c72116af962c6f462102976ea63b7 Mon Sep 17 00:00:00 2001 From: Nick Retallack Date: Tue, 7 Apr 2015 16:32:28 -0700 Subject: [PATCH] prevent password reset from breaking if you have no password If you've just been invited, or are using social auth, you have no password set, so the reset password feature causes a crash. This doesn't need to happen. --- flask_security/recoverable.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flask_security/recoverable.py b/flask_security/recoverable.py index 12ea264..491a940 100644 --- a/flask_security/recoverable.py +++ b/flask_security/recoverable.py @@ -53,7 +53,8 @@ def generate_reset_password_token(user): :param user: The user to work with """ - data = [str(user.id), md5(user.password)] + password_hash = md5(user.password) if user.password else None + data = [str(user.id), password_hash] return _security.reset_serializer.dumps(data)