Files
lotteryLaravel/app/Http/Controllers/Api/V1/Player/PlayerAuthLoginController.php
kang 2e0b257160
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
feat: enhance player authentication and agent management features
- Updated AGENTS.md to clarify player interface bindings and agent account restrictions.
- Improved PlayerAuthLoginController to include captcha verification for player login.
- Enhanced AdminPlayerIndexController with permission checks for admin users.
- Refactored AdminPlayerStoreController to enforce agent node restrictions for non-super admins.
- Introduced new error codes for player authentication failures and updated related services.
- Enhanced validation rules for agent profiles to include settlement cycle options.
- Improved AdminCaptchaService to support separate scopes for admin and player captcha handling.
- Updated various services to ensure proper credit management and settlement processes.
2026-06-17 15:27:00 +08:00

52 lines
1.6 KiB
PHP

<?php
namespace App\Http\Controllers\Api\V1\Player;
use App\Exceptions\PlayerAuthenticationException;
use App\Http\Controllers\Controller;
use App\Http\Requests\Player\PlayerAuthLoginRequest;
use App\Lottery\ErrorCode;
use App\Services\AdminCaptchaService;
use App\Services\Player\PlayerNativeAuthService;
use App\Support\ApiResponse;
use App\Support\LotteryMessage;
use Illuminate\Http\JsonResponse;
/** POST /api/v1/player/auth/login — 代理线下玩家账号密码登录 */
final class PlayerAuthLoginController extends Controller
{
public function __invoke(
PlayerAuthLoginRequest $request,
PlayerNativeAuthService $auth,
AdminCaptchaService $captcha,
): JsonResponse {
$data = $request->validated();
if (! $captcha->verify($data['captcha_key'], $data['captcha_code'], AdminCaptchaService::SCOPE_PLAYER)) {
return ApiResponse::error(
LotteryMessage::sso($request, ErrorCode::PlayerCaptchaInvalid->value),
ErrorCode::PlayerCaptchaInvalid->value,
null,
422,
);
}
try {
$data = $auth->login(
(string) $request->validated('site_code', ''),
(string) $request->validated('username'),
(string) $request->validated('password'),
);
} catch (PlayerAuthenticationException $e) {
return ApiResponse::error(
LotteryMessage::sso($request, $e->lotteryCode),
$e->lotteryCode,
null,
$e->httpStatus,
);
}
return ApiResponse::success($data);
}
}