-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/transaction itens user validation #108
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -14,6 +14,7 @@ | |||||
use Illuminate\Http\JsonResponse; | ||||||
use Illuminate\Http\Request; | ||||||
use Illuminate\Support\Facades\DB; | ||||||
use Illuminate\Validation\Rule; | ||||||
use OpenApi\Attributes as OA; | ||||||
use Symfony\Component\HttpKernel\Exception\HttpException; | ||||||
use Throwable; | ||||||
|
@@ -205,15 +206,23 @@ public function store(Request $request): JsonResponse | |||||
'description' => 'nullable|string', | ||||||
'datetime' => ['nullable', new Iso8601DateTime], | ||||||
'created_at' => ['nullable', new Iso8601DateTime], | ||||||
'group_id' => 'nullable|integer|exists:groups,id', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
'party_id' => 'nullable|integer|exists:parties,id', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to
Suggested change
|
||||||
'wallet_id' => 'nullable|integer|exists:wallets,id', | ||||||
'group_id' => ['nullable', 'integer', Rule::exists('groups', 'id')->where(function ($query) { | ||||||
$query->where('user_id', auth()->user()->id); | ||||||
})], | ||||||
'party_id' => ['nullable', 'integer', Rule::exists('parties', 'id')->where(function ($query) { | ||||||
$query->where('user_id', auth()->user()->id); | ||||||
})], | ||||||
'wallet_id' => ['nullable', 'integer', Rule::exists('wallets', 'id')->where(function ($query) { | ||||||
$query->where('user_id', auth()->user()->id); | ||||||
})], | ||||||
'categories' => 'nullable|array', | ||||||
'is_recurring' => 'nullable|boolean', | ||||||
'recurrence_period' => 'nullable|string|in:daily,weekly,monthly,yearly', | ||||||
'recurrence_interval' => 'nullable|integer|min:1', | ||||||
'recurrence_ends_at' => ['nullable', 'date', 'after:today', new Iso8601DateTime], | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The validation for
Suggested change
|
||||||
'categories.*' => 'integer|exists:categories,id', | ||||||
'categories.*' => ['integer', Rule::exists('categories', 'id')->where(function ($query) { | ||||||
$query->where('user_id', auth()->user()->id); | ||||||
})], | ||||||
'files' => 'nullable|array', | ||||||
'files.*' => 'file|mimes:jpg,jpeg,png,pdf|max:1240', | ||||||
]); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
group_id
validation in theupdate
method suffers from the same vulnerability asparty_id
andwallet_id
. Without scoping theexists
rule to the authenticated user's groups, a malicious user could link their transaction to another user's group. Update this validation rule to include theuser_id
check for enhanced security.