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
This commit is contained in:
Shridhar Patil 2018-06-29 15:52:29 +05:30 committed by Rushabh Mehta
parent 6b600e5981
commit 6ec17cc37d
2 changed files with 3 additions and 2 deletions

View file

@ -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"""

View file

@ -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 '*****'