From a44a5b170fdba94def3450c74384024a181a76b0 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 22 Feb 2024 13:49:08 +0100 Subject: [PATCH] add did for manual new user --- idhub/admin/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/idhub/admin/views.py b/idhub/admin/views.py index e720f22..1c0588d 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -283,7 +283,11 @@ class PeopleRegisterView(NotifyActivateUserByEmail, People, CreateView): return self.success_url def form_valid(self, form): - user = form.save() + super().form_valid(form) + user = form.instance + user.set_encrypted_sensitive_data() + user.save() + self.create_defaults_dids(user) messages.success(self.request, _('The account was created successfully')) Event.set_EV_USR_REGISTERED(user) Event.set_EV_USR_WELCOME(user) @@ -295,6 +299,11 @@ class PeopleRegisterView(NotifyActivateUserByEmail, People, CreateView): messages.error(self.request, e) return super().form_valid(form) + def create_defaults_dids(self, user): + did = DID(label="Default", user=user, type=DID.Types.WEB) + did.set_did() + did.save() + class PeopleMembershipRegisterView(People, FormView): template_name = "idhub/admin/people_membership_register.html"