From 6ec17cc37d4221a82097598bb938b662504b2c19 Mon Sep 17 00:00:00 2001 From: Shridhar Patil Date: Fri, 29 Jun 2018 15:52:29 +0530 Subject: [PATCH] ignore save password based on fieldname (#5749) * ignore save password based on fieldname * ignore save password if flag is True * if ignore_password is set then check for field --- frappe/core/doctype/user/user.py | 2 +- frappe/model/base_document.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frappe/core/doctype/user/user.py b/frappe/core/doctype/user/user.py index c5e73b52fe..7698a71a96 100644 --- a/frappe/core/doctype/user/user.py +++ b/frappe/core/doctype/user/user.py @@ -25,7 +25,7 @@ class User(Document): def __setup__(self): # because it is handled separately - self.flags.ignore_save_passwords = True + self.flags.ignore_save_passwords = ['new_password'] def autoname(self): """set name as Email Address""" diff --git a/frappe/model/base_document.py b/frappe/model/base_document.py index fcc8098b2b..ec89cdbe78 100644 --- a/frappe/model/base_document.py +++ b/frappe/model/base_document.py @@ -619,10 +619,11 @@ class BaseDocument(object): def _save_passwords(self): '''Save password field values in __Auth table''' - if self.flags.ignore_save_passwords: + if self.flags.ignore_save_passwords is True: return for df in self.meta.get('fields', {'fieldtype': ('=', 'Password')}): + if self.flags.ignore_save_passwords and df.fieldname in self.flags.ignore_save_passwords: continue new_password = self.get(df.fieldname) if new_password and not self.is_dummy_password(new_password): # is not a dummy password like '*****'