From 19ffe635eccf8a0ebbf8f2a6d489a1b4a4893b57 Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Mon, 24 Sep 2018 11:57:45 +0100 Subject: [PATCH] - fixed initdb.py to set empty passwords by default --- initdb.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/initdb.py b/initdb.py index 0f78dd4..94e7057 100755 --- a/initdb.py +++ b/initdb.py @@ -83,9 +83,12 @@ def get_students_from_csv(filename): # replace password by hash for a single student def hashpw(student, pw=None): print('.', end='', flush=True) - pw = (pw or student.get('pw', None) or student['uid']).encode('utf-8') - student['pw'] = bcrypt.hashpw(pw, bcrypt.gensalt()) - + # pw = (pw or student.get('pw', None) or student['uid']).encode('utf-8') + if pw is None: + student['pw'] = '' + else: + student['pw'] = bcrypt.hashpw(pw.encode('utf-8'), bcrypt.gensalt()) + # =========================================================================== def insert_students_into_db(session, students): -- libgit2 0.21.2