fix some things

This commit is contained in:
Cayo Puigdefabregas 2024-01-18 20:32:40 +01:00
parent 22e532f1cb
commit c5ae51bee9
2 changed files with 8 additions and 3 deletions

View File

@ -588,13 +588,15 @@ class VerificableCredential(models.Model):
# cache.get("KEY_DIDS"),
# settings.SECRET_KEY,
# )
# hash of credential without sign
self.hash = hashlib.sha3_256(self.render(domain).encode()).hexdigest()
data = sign_credential(
self.render(domain),
self.issuer_did.get_key_material(issuer_pass)
)
if self.eidas1_did:
self.data = data
self.hash = hashlib.sha3_256(self.data.encode()).hexdigest()
else:
self.data = self.user.encrypt_data(data, password)
@ -606,13 +608,15 @@ class VerificableCredential(models.Model):
issuance_date = self.issued_on.strftime(format)
cred_path = 'credentials'
sid = self.id
if self.eidas1_did:
cred_path = 'public/credentials'
sid = self.hash
url_id = "{}/{}/{}".format(
domain,
cred_path,
self.id
sid
)
context = {

View File

@ -26,6 +26,7 @@ from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse_lazy
from django.http import HttpResponse
from django.contrib import messages
from django.core.cache import cache
from django.conf import settings
from idhub.user.forms import (
ProfileForm,
@ -132,9 +133,9 @@ class CredentialPdfView(MyWallet, TemplateView):
subtitle = _('Credential management')
icon = 'bi bi-patch-check-fill'
file_name = "certificate.pdf"
_pss = '123456'
def get(self, request, *args, **kwargs):
self.admin_validated = cache.get("KEY_DIDS")
pk = kwargs['pk']
self.user = self.request.user
self.object = get_object_or_404(