Skip to content

Commit

Permalink
Fix: Use text field for acceptance token and credential JWT
Browse files Browse the repository at this point in the history
Signed-off-by: George J Padayatti <[email protected]>
  • Loading branch information
georgepadayatti committed May 2, 2024
1 parent 6c3a6b0 commit e3d0b80
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 18 deletions.
18 changes: 18 additions & 0 deletions certificate/migrations/0004_auto_20240502_0831.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.0.7 on 2024-05-02 08:31

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('certificate', '0003_openid4vccertificate_credentialjwt'),
]

operations = [
migrations.AlterField(
model_name='openid4vccertificate',
name='acceptance_token',
field=models.TextField(blank=True, null=True),
),
]
18 changes: 18 additions & 0 deletions certificate/migrations/0005_auto_20240502_0839.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.0.7 on 2024-05-02 08:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('certificate', '0004_auto_20240502_0831'),
]

operations = [
migrations.AlterField(
model_name='openid4vccertificate',
name='credentialJwt',
field=models.TextField(blank=True, null=True),
),
]
4 changes: 2 additions & 2 deletions certificate/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class Certificates(models.Model):

class OpenID4VCCertificate(models.Model):
user = models.ForeignKey(IGrantUser, on_delete=models.CASCADE)
acceptance_token = models.CharField(max_length=256, null=True, blank=True)
acceptance_token = models.TextField(null=True, blank=True)
credential = JSONField(default={}, blank=True)
credentialJwt = models.CharField(max_length=256, null=True, blank=True)
credentialJwt = models.TextField(null=True, blank=True)
status = models.CharField(
max_length=250, null=False, blank=False, default="pending"
)
Expand Down
31 changes: 15 additions & 16 deletions certificate/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,22 @@ def get_certificates(request):
pending_oid4vc_certificate.save()

certificate_response = response.json()
if certificate_response.get("results"):
if isinstance(certificate_response.get("results"), list):
ready_oid4vc_certificates = OpenID4VCCertificate.objects.filter(
status="ready"
if isinstance(certificate_response.get("results"), list):
ready_oid4vc_certificates = OpenID4VCCertificate.objects.filter(
status="ready"
)
for ready_oid4vc_certificate in ready_oid4vc_certificates:
certificate_response.get("results").append(
{
"referent": ready_oid4vc_certificate.acceptance_token,
"attrs": ready_oid4vc_certificate.credential,
"schema_id": "Nej8DViZyVvfyaLqGgWUw2:2:Legal Personal Identification Data (LPID):2.0.0",
"cred_def_id": "Nej8DViZyVvfyaLqGgWUw2:3:CL:84:default",
"rev_reg_id": None,
"cred_rev_id": None,
"credentialJwt": ready_oid4vc_certificate.credentialJwt,
}
)
for ready_oid4vc_certificate in ready_oid4vc_certificates:
certificate_response.get("results").append(
{
"referent": ready_oid4vc_certificate.acceptance_token,
"attrs": ready_oid4vc_certificate.credential,
"schema_id": "Nej8DViZyVvfyaLqGgWUw2:2:Legal Personal Identification Data (LPID):2.0.0",
"cred_def_id": "Nej8DViZyVvfyaLqGgWUw2:3:CL:84:default",
"rev_reg_id": None,
"cred_rev_id": None,
"credentialJwt": ready_oid4vc_certificate.credentialJwt,
}
)
return Response(certificate_response, status=response.status_code)


Expand Down

0 comments on commit e3d0b80

Please sign in to comment.