encripted y download credential

This commit is contained in:
Cayo Puigdefabregas 2024-01-04 21:11:11 +01:00
parent 10c6d20a10
commit 5dc1577d9e
2 changed files with 5 additions and 4 deletions

View File

@ -3,7 +3,6 @@ import pytz
import datetime
from django.db import models
from django.conf import settings
from django.core.cache import cache
from django.template.loader import get_template
from django.utils.translation import gettext_lazy as _
from nacl import secret
@ -541,13 +540,15 @@ class VerificableCredential(models.Model):
if self.status == self.Status.ISSUED:
return
self.status = self.Status.ISSUED
# self.status = self.Status.ISSUED
import pdb; pdb.set_trace()
self.subject_did = did
self.issued_on = datetime.datetime.now().astimezone(pytz.utc)
self.data = sign_credential(
data = sign_credential(
self.render(),
self.issuer_did.get_key_material()
)
self.data = self.user.encrypt_data(data)
def get_context(self):
d = json.loads(self.csv_data)

View File

@ -120,7 +120,7 @@ class CredentialJsonView(MyWallet, TemplateView):
pk=pk,
user=self.request.user
)
response = HttpResponse(self.object.data, content_type="application/json")
response = HttpResponse(self.object.get_data(), content_type="application/json")
response['Content-Disposition'] = 'attachment; filename={}'.format("credential.json")
return response