diff --git a/idhub/models.py b/idhub/models.py index 10e0ceb..378872f 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -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 = { diff --git a/idhub/user/views.py b/idhub/user/views.py index 49d5229..aa0b2a7 100644 --- a/idhub/user/views.py +++ b/idhub/user/views.py @@ -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(