From d9ccc8bbb3763b0ec70482b4c78fe9f9dcd3c498 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 27 Feb 2024 19:33:40 +0100 Subject: [PATCH] add code of oidc4vp in dashboard --- idhub/models.py | 8 ++++++++ idhub/user/views.py | 1 + oidc4vp/views.py | 1 + 3 files changed, 10 insertions(+) diff --git a/idhub/models.py b/idhub/models.py index ae4625b..f1eea85 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -54,6 +54,7 @@ class Event(models.Model): EV_USR_DEACTIVATED_BY_ADMIN = 30, "User deactivated" EV_USR_ACTIVATED_BY_ADMIN = 31, "User activated" EV_USR_SEND_VP = 32, "User send Verificable Presentation" + EV_USR_SEND_CREDENTIAL = 33, "User send credential" created = models.DateTimeField(_("Date"), auto_now=True) message = models.CharField(_("Description"), max_length=350) @@ -417,6 +418,13 @@ class Event(models.Model): user=user ) + @classmethod + def set_EV_USR_SEND_CREDENTIAL(cls, msg): + cls.objects.create( + type=cls.Types.EV_USR_SEND_CREDENTIAL, + message=msg, + ) + class DID(models.Model): class Types(models.IntegerChoices): diff --git a/idhub/user/views.py b/idhub/user/views.py index 4d07540..984c6b9 100644 --- a/idhub/user/views.py +++ b/idhub/user/views.py @@ -80,6 +80,7 @@ class DashboardView(UserView, SingleTableView): Event.Types.EV_CREDENTIAL_PRESENTED, # Credential presented Event.Types.EV_CREDENTIAL_CAN_BE_REQUESTED, # Credential available Event.Types.EV_CREDENTIAL_REVOKED, # Credential revoked + Event.Types.EV_USR_SEND_VP, # User send verificable presentation ] return events_for_users diff --git a/oidc4vp/views.py b/oidc4vp/views.py index fb869ce..5da6e2e 100644 --- a/oidc4vp/views.py +++ b/oidc4vp/views.py @@ -79,6 +79,7 @@ class AuthorizeView(UserView, FormView): elif authorization.get('response'): txt = authorization.get('response') messages.success(self.request, txt) + Event.set_EV_USR_SEND_CREDENTIAL(txt) txt2 = f"Verifier {verifier} send: " + txt Event.set_EV_USR_SEND_VP(txt2, self.request.user) url = reverse_lazy('idhub:user_dashboard')