Update migrate_passwords_passlib.py
"code is poetry"
This commit is contained in:
parent
cf6fcce961
commit
52aed5e592
1 changed files with 4 additions and 6 deletions
|
|
@ -4,17 +4,15 @@ from frappe.utils.password import LegacyPassword
|
|||
|
||||
def execute():
|
||||
all_auths = frappe.db.sql("""SELECT `name`, `password`, `salt` FROM `__Auth`
|
||||
WHERE doctype='User' AND `fieldname`='password'""",
|
||||
as_dict=True
|
||||
)
|
||||
WHERE doctype='User' AND `fieldname`='password'""",
|
||||
as_dict=True)
|
||||
|
||||
for auth in all_auths:
|
||||
if auth.salt and auth.salt != "":
|
||||
pwd = LegacyPassword.hash(auth.password, salt=auth.salt.encode('UTF-8'))
|
||||
frappe.db.sql("""UPDATE `__Auth` SET `password`=%(pwd)s, `salt`=NULL
|
||||
WHERE `doctype`='User' AND `fieldname`='password' AND `name`=%(user)s""",
|
||||
{'pwd': pwd, 'user': auth.name}
|
||||
)
|
||||
WHERE `doctype`='User' AND `fieldname`='password' AND `name`=%(user)s""",
|
||||
{'pwd': pwd, 'user': auth.name})
|
||||
|
||||
frappe.reload_doctype("User")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue