From f8574569ac938a6d7bea5efc025819966a493f6b Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Wed, 24 Jan 2024 16:53:19 +0100 Subject: [PATCH] fix vp with new type in credentials --- idhub/models.py | 12 +----------- oidc4vp/forms.py | 6 +++--- oidc4vp/templates/credentials_presentation.html | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/idhub/models.py b/idhub/models.py index d5e44ef..ec808d9 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -610,17 +610,7 @@ class VerificableCredential(models.Model): return '' def get_type(self, lang=None): - schema = json.loads(self.schema.data) - if not schema.get('name'): - return '' - try: - for x in schema['name']: - if lang or settings.LANGUAGE_CODE in x['lang']: - return x.get('value', '') - except: - return self.schema.type - - return '' + return self.type def get_status(self): return self.Status(self.status).label diff --git a/oidc4vp/forms.py b/oidc4vp/forms.py index ea32d38..560531c 100644 --- a/oidc4vp/forms.py +++ b/oidc4vp/forms.py @@ -35,8 +35,8 @@ class AuthorizeForm(forms.Form): for vp in self.presentation_definition: vp = vp.lower() choices = [ - (str(x.id), x.schema.type.lower()) for x in self.credentials.filter( - schema__type__iexact=vp) + (str(x.id), x.type.lower()) for x in self.credentials.filter( + type__iexact=vp) ] self.fields[vp.lower()] = forms.ChoiceField( widget=forms.RadioSelect, @@ -46,7 +46,7 @@ class AuthorizeForm(forms.Form): data = super().clean() self.list_credentials = [] for c in self.credentials: - if str(c.id) == data.get(c.schema.type.lower()): + if str(c.id) == data.get(c.type.lower()): if c.status is not c.Status.ISSUED.value or not c.data: txt = _('There are some problems with this credentials') raise ValidationError(txt) diff --git a/oidc4vp/templates/credentials_presentation.html b/oidc4vp/templates/credentials_presentation.html index 41629c8..076f601 100644 --- a/oidc4vp/templates/credentials_presentation.html +++ b/oidc4vp/templates/credentials_presentation.html @@ -43,7 +43,7 @@ {% for f in form.credentials.all %} - {% if f.schema.type.lower == presentation.lower %} + {% if f.type.lower == presentation.lower %} {{ f.type }}