Fix data validation

This commit is contained in:
Yarmo Mackenbach 2022-10-27 12:29:32 +02:00
parent 2b435080ba
commit 3f48cc55ba
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1

View file

@ -116,7 +116,7 @@ const apiProfileSchema = {
} }
}, },
claim: { claim: {
type: "object", type: ["array", "object"],
properties: { properties: {
format: { type: "string" }, format: { type: "string" },
relation: { type: "string" }, relation: { type: "string" },
@ -328,7 +328,7 @@ router.get('/profile/fetch',
try { try {
// Sanitize JSON // Sanitize JSON
data = sanitize(data); data = sanitize(data)
} catch (error) { } catch (error) {
data.keyData = {} data.keyData = {}
data.extra = {} data.extra = {}
@ -350,7 +350,7 @@ router.get('/profile/fetch',
router.get('/profile/verify', router.get('/profile/verify',
check('data').exists().isJSON(), check('data').exists().isJSON(),
async (req, res) => { async (req, res) => {
const valRes = validationResult(req); const valRes = validationResult(req)
if (!valRes.isEmpty()) { if (!valRes.isEmpty()) {
res.status(400).send(valRes) res.status(400).send(valRes)
return return