revoke only didwebs

This commit is contained in:
Cayo Puigdefabregas 2024-02-14 17:33:24 +01:00
parent 2e7abc4bdd
commit 0fed4b914d
1 changed files with 9 additions and 4 deletions

View File

@ -602,7 +602,7 @@ class VerificableCredential(models.Model):
if not self.data: if not self.data:
return "" return ""
if self.eidas1_did or self.is_didweb: if self.eidas1_did:
return self.data return self.data
return self.user.decrypt_data(self.data, password) return self.user.decrypt_data(self.data, password)
@ -648,7 +648,7 @@ class VerificableCredential(models.Model):
self.render(domain), self.render(domain),
self.issuer_did.get_key_material(issuer_pass) self.issuer_did.get_key_material(issuer_pass)
) )
if self.eidas1_did or self.is_didweb: if self.eidas1_did:
self.data = data self.data = data
else: else:
self.data = self.user.encrypt_data(data, password) self.data = self.user.encrypt_data(data, password)
@ -662,7 +662,7 @@ class VerificableCredential(models.Model):
cred_path = 'credentials' cred_path = 'credentials'
sid = self.id sid = self.id
if self.eidas1_did or self.is_didweb: if self.eidas1_did:
cred_path = 'public/credentials' cred_path = 'public/credentials'
sid = self.hash sid = self.hash
@ -673,7 +673,7 @@ class VerificableCredential(models.Model):
) )
context = { context = {
'id_credential': self.id, 'id_credential': str(self.id),
'vc_id': url_id, 'vc_id': url_id,
'issuer_did': self.issuer_did.did, 'issuer_did': self.issuer_did.did,
'subject_did': self.subject_did and self.subject_did.did or '', 'subject_did': self.subject_did and self.subject_did.did or '',
@ -694,6 +694,11 @@ class VerificableCredential(models.Model):
tmpl = get_template(template_name) tmpl = get_template(template_name)
d_ordered = ujson.loads(tmpl.render(context)) d_ordered = ujson.loads(tmpl.render(context))
d_minimum = self.filter_dict(d_ordered) d_minimum = self.filter_dict(d_ordered)
# You can revoke only didweb
if not self.is_didweb:
d_minimum.pop("credentialStatus", None)
return ujson.dumps(d_minimum) return ujson.dumps(d_minimum)
def get_issued_on(self): def get_issued_on(self):