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

Validate settings categories by checking for existing views #5255

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 3 additions & 5 deletions app/Settings/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

class SettingController extends Controller
{
protected array $settingCategories = ['features', 'customization', 'registration'];

/**
* Handle requests to the settings index path.
*/
Expand All @@ -31,7 +29,7 @@ public function category(string $category)
// Get application version
$version = trim(file_get_contents(base_path('version')));

return view('settings.' . $category, [
return view('settings.categories.' . $category, [
'category' => $category,
'version' => $version,
'guestUser' => User::getGuest(),
Expand Down Expand Up @@ -59,8 +57,8 @@ public function update(Request $request, AppSettingsStore $store, string $catego

protected function ensureCategoryExists(string $category): void
{
if (!in_array($category, $this->settingCategories)) {
abort(404);
if (!view()->exists('settings.categories.' . $category)) {
abort(404, 'Category not found');
}
}
}