add did for new user from import excel

This commit is contained in:
Cayo Puigdefabregas 2024-02-22 13:50:07 +01:00
parent a44a5b170f
commit d218df4ddc
1 changed files with 8 additions and 5 deletions

View File

@ -257,18 +257,21 @@ class ImportForm(forms.Form):
except jsonschema.exceptions.ValidationError as err: except jsonschema.exceptions.ValidationError as err:
msg = "line {}: {}".format(line+1, err) msg = "line {}: {}".format(line+1, err)
return self.exception(msg) return self.exception(msg)
# try:
# check = credtools.validate_json(row, self.json_schema)
# if check is not True:
# raise ValidationError("Not valid row")
# except Exception as e:
user, new = User.objects.get_or_create(email=row.get('email')) user, new = User.objects.get_or_create(email=row.get('email'))
if new: if new:
self.users.append(user) self.users.append(user)
user.set_encrypted_sensitive_data()
user.save()
self.create_defaults_dids(user)
return user return user
def create_defaults_dids(self, user):
did = DID(label="Default", user=user, type=DID.Types.WEB)
did.set_did()
did.save()
def create_credential(self, user, row): def create_credential(self, user, row):
bcred = VerificableCredential.objects.filter( bcred = VerificableCredential.objects.filter(
user=user, user=user,