Added liking and security measures
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user