change verify_presentation for verify_vp

This commit is contained in:
Cayo Puigdefabregas 2024-06-06 13:49:15 +02:00
parent 1651667717
commit 2720690320

View file

@ -12,7 +12,7 @@ from django.http import QueryDict
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from idhub_auth.models import User from idhub_auth.models import User
from django.db import models from django.db import models
from utils.idhub_ssikit import verify_presentation from pyvckit.verify_vp import verify_vp
SALT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" SALT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
@ -271,7 +271,7 @@ class OAuth2VPToken(models.Model):
return self.authorization.code return self.authorization.code
def verifing(self): def verifing(self):
self.result_verify = verify_presentation(self.vp_token) self.result_verify = verify_vp(self.vp_token)
def get_result_verify(self): def get_result_verify(self):
if not self.result_verify: if not self.result_verify:
@ -284,8 +284,7 @@ class OAuth2VPToken(models.Model):
"redirect_uri": "", "redirect_uri": "",
"response": "", "response": "",
} }
verification = json.loads(self.result_verify) if not self.result_verify:
if verification.get('errors') or verification.get('warnings'):
response["verify"] = "Error, {}".format(_("Failed verification")) response["verify"] = "Error, {}".format(_("Failed verification"))
return response return response