fix: Add checks for users in keys

This commit is contained in:
Yarmo Mackenbach 2023-03-01 15:51:52 +01:00
parent 01389957fb
commit f418b6cf8f
2 changed files with 43 additions and 21 deletions

View file

@ -196,6 +196,11 @@ const doVerification = async (data) => {
} }
} }
// Return early if no users in key
if (!data.keyData.users) {
return data
}
for (let iUser = 0; iUser < data.keyData.users.length; iUser++) { for (let iUser = 0; iUser < data.keyData.users.length; iUser++) {
const user = data.keyData.users[iUser] const user = data.keyData.users[iUser]
@ -225,6 +230,7 @@ const doVerification = async (data) => {
const sanitize = (data) => { const sanitize = (data) => {
const dataClone = JSON.parse(JSON.stringify(data)) const dataClone = JSON.parse(JSON.stringify(data))
if (dataClone.keyData.users) {
for (let iUser = 0; iUser < dataClone.keyData.users.length; iUser++) { for (let iUser = 0; iUser < dataClone.keyData.users.length; iUser++) {
const user = dataClone.keyData.users[iUser] const user = dataClone.keyData.users[iUser]
@ -252,6 +258,7 @@ const sanitize = (data) => {
data.keyData.users[iUser].claims[iClaim] = claim data.keyData.users[iUser].claims[iClaim] = claim
} }
} }
}
const valid = apiProfileValidate(data) const valid = apiProfileValidate(data)
if (!valid) { if (!valid) {
@ -262,6 +269,11 @@ const sanitize = (data) => {
} }
const addSummaryToClaims = (data) => { const addSummaryToClaims = (data) => {
// Return early if no users in key
if (!data.keyData.users) {
return data
}
// To be removed when data is added by DOIP library // To be removed when data is added by DOIP library
for (let userIndex = 0; userIndex < data.keyData.users.length; userIndex++) { for (let userIndex = 0; userIndex < data.keyData.users.length; userIndex++) {
const user = data.keyData.users[userIndex] const user = data.keyData.users[userIndex]

View file

@ -199,6 +199,11 @@ const doVerification = async (data) => {
} }
} }
// Return early if no users in key
if (!data.keyData.users) {
return data
}
for (let iUser = 0; iUser < data.keyData.users.length; iUser++) { for (let iUser = 0; iUser < data.keyData.users.length; iUser++) {
const user = data.keyData.users[iUser] const user = data.keyData.users[iUser]
@ -235,6 +240,11 @@ const sanitize = (data) => {
} }
const addSummaryToClaims = (data) => { const addSummaryToClaims = (data) => {
// Return early if no users in key
if (!data.keyData.users) {
return data
}
// To be removed when data is added by DOIP library // To be removed when data is added by DOIP library
for (let userIndex = 0; userIndex < data.keyData.users.length; userIndex++) { for (let userIndex = 0; userIndex < data.keyData.users.length; userIndex++) {
const user = data.keyData.users[userIndex] const user = data.keyData.users[userIndex]