Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Add Authorization Check to saveToList #137

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion code/web/services/MyAccount/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -7085,14 +7085,25 @@ function saveToList() {
$totalRecords = 0;
} else {
$userList->id = $listId;
$totalRecords = $userList->numValidListItems();
// $totalRecords = $userList->numValidListItems();
if (!$userList->find(true)) {
$result['success'] = false;
$result['message'] = translate([
'text' => 'Sorry, we could not find that list in the system.',
'isPublicFacing' => true,
]);
$listOk = false;
} else {
//Authorization check: Ensure list belongs to logged in user
if ($userList->user_id != UserAccount::getActiveUserId()) {
$result['success'] = false;
$result['message'] =translate([
'text' => 'You are not authorized to modify this list.',
'isPublicFacing' => true,
]);
return $result;
}
$totalRecords = $userList->numValidListItems();
}
}

Expand Down
Loading