Added liking and security measures

This commit is contained in:
Sven laptop
2026-07-31 15:11:57 +02:00
parent 494b583cbc
commit ab73eecfec
25 changed files with 1095 additions and 91 deletions
+15 -1
View File
@@ -121,6 +121,16 @@ function cleanProfileUpdateInput(input) {
}
}
if (body.private !== undefined) {
if (typeof body.private === 'boolean') {
values.private = body.private;
} else if (body.private === 'true' || body.private === 'false') {
values.private = body.private === 'true';
} else {
values.private = null;
}
}
return values;
}
@@ -148,10 +158,14 @@ function validateOptionalPersonField(field, value) {
function validateProfileUpdateInput(values, { hasImageChange = false } = {}) {
const changeFields = ['name', 'username', 'email', 'password'].filter((field) => values[field] !== undefined);
if (changeFields.length === 0 && !hasImageChange) {
if (changeFields.length === 0 && values.private === undefined && !hasImageChange) {
throw new Error('At least one profile field must be changed');
}
if (values.private === null) {
throw new Error('private must be true or false');
}
if (values.password !== undefined && values.current_password === undefined) {
throw new Error('current_password is required when changing password');
}