fix check credentials in loop

This commit is contained in:
Cayo Puigdefabregas 2023-12-14 12:48:46 +01:00
parent 69d1873da4
commit fcc4b34424
1 changed files with 21 additions and 13 deletions

View File

@ -258,6 +258,7 @@ class AllowCodeOidc4vpView(GenericMixin):
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Authorization': f'Bearer {WALLET_INX_EBSI_PLUGIN_TOKEN}' 'Authorization': f'Bearer {WALLET_INX_EBSI_PLUGIN_TOKEN}'
} }
for v in vcredential:
data = json.dumps({ data = json.dumps({
"type": "VerificationRequest", "type": "VerificationRequest",
"jwtCredential": vcredential[0] "jwtCredential": vcredential[0]
@ -267,15 +268,22 @@ class AllowCodeOidc4vpView(GenericMixin):
headers=headers, headers=headers,
data=data data=data
) )
if result.status_code != 200: if result.status_code != 200:
return return
vps = json.loads(result.text) vps = json.loads(result.text)
try:
roles = vps['credential']['credentialSubject'].get('role')
except Exception:
roles = None
if roles:
break
if not vps.get('verified'): if not vps.get('verified'):
return return
return vps['credential']['credentialSubject'].get('role') return roles
def get_response_uri(selfi, roles): def get_response_uri(selfi, roles):
code = Code2Roles(roles=roles) code = Code2Roles(roles=roles)