handle password the correct way

This commit is contained in:
Pierre-antoine Comby 2020-02-23 14:23:02 +01:00
parent efe32e45bf
commit 889ddc15f8
1 changed files with 7 additions and 3 deletions

View File

@ -62,14 +62,20 @@ class Command(BaseCommand):
for row in cur: for row in cur:
row["idbde"] += 7 # do not overwrite the already populated id. row["idbde"] += 7 # do not overwrite the already populated id.
if row["type"] == "personne": if row["type"] == "personne":
#sanitize password
if row["passwd"] != "*|*":
passwd_nk15 = "$".join(["custom_nk15","1",row["passwd"]])
else:
passwd_nk15 = ''
try: try:
user = User.objects.create( user = User.objects.create(
username =row["pseudo"], username =row["pseudo"],
password = row["passwd"] if row["passwd"] != '*|*' else '', password = passwd_nk15,
first_name = row["nom"], first_name = row["nom"],
last_name = row["prenom"], last_name = row["prenom"],
email = row["mail"], email = row["mail"],
) )
#sanitize duplicate aliases (nk12)
except ValidationError as e: except ValidationError as e:
if e.code == 'same_alias': if e.code == 'same_alias':
user = User.objects.create( user = User.objects.create(
@ -79,8 +85,6 @@ class Command(BaseCommand):
last_name = row["prenom"], last_name = row["prenom"],
email = row["mail"], email = row["mail"],
) )
profile = Profile.objects.create( profile = Profile.objects.create(
phone_number = row["tel"], phone_number = row["tel"],
address = row["adresse"], address = row["adresse"],