Skip to content

Commit 4d066ab

Browse files
committed
Add some missing authorization checks
1 parent bc924de commit 4d066ab

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/Http/Livewire/Pages/CategoryCreate.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class CategoryCreate extends Component
3838

3939
public function mount(Request $request)
4040
{
41+
if (!CategoryAuthorization::create($request->user())) {
42+
abort(404);
43+
}
44+
4145
$categories = CategoryAccess::getFilteredTreeFor($request->user())->toTree();
4246

4347
// TODO: This is a workaround for a serialisation issue. See: https://github.com/lazychaser/laravel-nestedset/issues/487

src/Http/Livewire/Pages/CategoryEdit.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ class CategoryEdit extends Component
3939

4040
public function mount(Request $request)
4141
{
42+
$category = $request->route('category');
43+
44+
if (!CategoryAuthorization::edit($request->user(), $category)) {
45+
abort(404);
46+
}
47+
4248
$categories = CategoryAccess::getFilteredTreeFor($request->user())->toTree();
4349

4450
// TODO: This is a workaround for a serialisation issue. See: https://github.com/lazychaser/laravel-nestedset/issues/487
4551
// Once the issue is fixed, this can be removed.
4652
$this->categories = CategoryAccess::removeParentRelationships($categories);
4753

48-
$category = $request->route('category');
4954
$this->category = $category;
5055
$this->title = $category->title;
5156
$this->description = $category->description ?? "";

src/Http/Livewire/Pages/ThreadCreate.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public function mount(Request $request)
3232
$this->category = $request->route('category');
3333
$this->breadcrumbs_append = [trans('forum::threads.new_thread')];
3434

35+
if (!CategoryAuthorization::createThreads($request->user(), $this->category)) {
36+
abort(403);
37+
}
38+
3539
UserCreatingThread::dispatch($request->user(), $this->category);
3640
}
3741

0 commit comments

Comments
 (0)