mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
implement MaxStringLenghts
This commit is contained in:
parent
ee120f0cd0
commit
5f6a1738e3
@ -12,6 +12,12 @@ const AllowedPublicUpdateFields = [
|
|||||||
"description",
|
"description",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const MaxStringsLengths = {
|
||||||
|
fullName: 120,
|
||||||
|
email: 320,
|
||||||
|
description: 2000,
|
||||||
|
}
|
||||||
|
|
||||||
export default class UserController extends Controller {
|
export default class UserController extends Controller {
|
||||||
static refName = "UserController"
|
static refName = "UserController"
|
||||||
|
|
||||||
@ -376,6 +382,14 @@ export default class UserController extends Controller {
|
|||||||
|
|
||||||
AllowedPublicUpdateFields.forEach((key) => {
|
AllowedPublicUpdateFields.forEach((key) => {
|
||||||
if (typeof req.selection.update[key] !== "undefined") {
|
if (typeof req.selection.update[key] !== "undefined") {
|
||||||
|
// sanitize update
|
||||||
|
// check maximung strings length
|
||||||
|
if (typeof req.selection.update[key] === "string" && MaxStringsLengths[key]) {
|
||||||
|
if (req.selection.update[key].length > MaxStringsLengths[key]) {
|
||||||
|
return res.status(400).json({ error: `${key} is too long` })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
update[key] = req.selection.update[key]
|
update[key] = req.selection.update[key]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user