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,24 +258,32 @@ 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}'
} }
data = json.dumps({ for v in vcredential:
"type": "VerificationRequest", data = json.dumps({
"jwtCredential": vcredential[0] "type": "VerificationRequest",
}) "jwtCredential": vcredential[0]
result = requests.post( })
WALLET_INX_EBSI_PLUGIN_URL, result = requests.post(
headers=headers, WALLET_INX_EBSI_PLUGIN_URL,
data=data headers=headers,
) data=data
)
if result.status_code != 200:
return
if result.status_code != 200: vps = json.loads(result.text)
return try:
roles = vps['credential']['credentialSubject'].get('role')
except Exception:
roles = None
if roles:
break
vps = json.loads(result.text)
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)