feat: enhance agent management and validation logic
- Updated AGENTS.md to clarify agent account restrictions and permissions. - Implemented checks in AgentNodeAdminUserStoreController and AgentNodeRoleStoreController to restrict admin user and role creation to the agent's own node. - Enhanced validation in AdminPlayerStoreController and AdminPlayerUpdateController to enforce credit limit and rebate rate rules based on player funding mode. - Refactored various request classes to utilize shared admin account field rules for consistency. - Improved error handling in services related to credit allocation and rebate limits to ensure proper validation and messaging.
This commit is contained in:
61
app/Http/Requests/Admin/Concerns/AdminAccountFieldRules.php
Normal file
61
app/Http/Requests/Admin/Concerns/AdminAccountFieldRules.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin\Concerns;
|
||||
|
||||
trait AdminAccountFieldRules
|
||||
{
|
||||
/** @return array<int, mixed> */
|
||||
protected function adminLoginAccountRules(bool $required = true): array
|
||||
{
|
||||
$rules = ['string', 'min:2', 'max:64', 'regex:/^[a-zA-Z0-9._-]+$/u'];
|
||||
|
||||
return $required ? array_merge(['required'], $rules) : array_merge(['sometimes'], $rules);
|
||||
}
|
||||
|
||||
/** @return array<int, mixed> */
|
||||
protected function adminLoginPasswordRules(bool $required = true, int $min = 8, int $max = 256): array
|
||||
{
|
||||
$rules = ['string', 'min:'.$min, 'max:'.$max];
|
||||
|
||||
if ($required) {
|
||||
return array_merge(['required'], $rules);
|
||||
}
|
||||
|
||||
return array_merge(['sometimes', 'nullable'], $rules);
|
||||
}
|
||||
|
||||
/** @return array<int, mixed> */
|
||||
protected function adminOperatorUsernameRules(bool $required = true): array
|
||||
{
|
||||
$rules = ['string', 'min:2', 'max:64', 'regex:/^[a-zA-Z0-9._-]+$/u'];
|
||||
|
||||
return $required ? array_merge(['required'], $rules) : array_merge(['sometimes'], $rules);
|
||||
}
|
||||
|
||||
/** @return array<int, mixed> */
|
||||
protected function nativePlayerUsernameRules(bool $required = false): array
|
||||
{
|
||||
$rules = ['string', 'min:2', 'max:64', 'regex:/^[a-zA-Z0-9._-]+$/u'];
|
||||
|
||||
return $required ? array_merge(['required'], $rules) : array_merge(['nullable'], $rules);
|
||||
}
|
||||
|
||||
/** @return array<int, mixed> */
|
||||
protected function nativePlayerPasswordRules(bool $required = false): array
|
||||
{
|
||||
$rules = ['string', 'min:6', 'max:128'];
|
||||
|
||||
return $required ? array_merge(['required'], $rules) : array_merge(['nullable'], $rules);
|
||||
}
|
||||
|
||||
protected function normalizeAdminAccountFields(): void
|
||||
{
|
||||
if ($this->has('account')) {
|
||||
$this->merge(['account' => strtolower(trim((string) $this->input('account')))]);
|
||||
}
|
||||
|
||||
if ($this->has('username')) {
|
||||
$this->merge(['username' => strtolower(trim((string) $this->input('username')))]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user