From 15daa1ac4e9c605d24f13223539944e3721ffb4c Mon Sep 17 00:00:00 2001 From: Bruno Bonfils Date: Mon, 24 Feb 2020 08:58:30 +0100 Subject: [PATCH] Fix #299 (test if password is None in user_mixin) --- flask_user/user_mixin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flask_user/user_mixin.py b/flask_user/user_mixin.py index daaac8f0..96afb010 100644 --- a/flask_user/user_mixin.py +++ b/flask_user/user_mixin.py @@ -23,7 +23,7 @@ def get_id(self): user_manager = current_app.user_manager user_id = self.id - password_ends_with = '' if user_manager.USER_ENABLE_AUTH0 else self.password[-8:] + password_ends_with = '' if user_manager.USER_ENABLE_AUTH0 or self.password is None else self.password[-8:] user_token = user_manager.generate_token( user_id, # User ID password_ends_with, # Last 8 characters of user password @@ -49,7 +49,7 @@ def get_user_by_token(cls, token, expiration_in_seconds=None): user_id = data_items[0] password_ends_with = data_items[1] user = user_manager.db_manager.get_user_by_id(user_id) - user_password = '' if user_manager.USER_ENABLE_AUTH0 else user.password[-8:] + user_password = '' if user_manager.USER_ENABLE_AUTH0 or user.password is None else user.password[-8:] # Make sure that last 8 characters of user password matches token_is_valid = user and user_password==password_ends_with