vmangos
This commit is contained in:
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Http\Controllers\Concerns\BuildsPortalProps;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\UpdateAccountAccessRequest;
|
||||
use App\Services\AzerothCoreAccountService;
|
||||
use App\Services\VMangosAccountService;
|
||||
use App\Services\InviteCodeService;
|
||||
use App\Support\WowData;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -19,15 +19,15 @@ class AccountController extends Controller
|
||||
|
||||
public function index(
|
||||
Request $request,
|
||||
AzerothCoreAccountService $accounts,
|
||||
VMangosAccountService $accounts,
|
||||
InviteCodeService $inviteCodes,
|
||||
): Response {
|
||||
$search = trim((string) $request->query('search', ''));
|
||||
$searchTerm = $search !== '' ? $search : null;
|
||||
$activeTab = (string) $request->query('tab', AzerothCoreAccountService::ACCOUNT_TAB_PLAYERS);
|
||||
$activeTab = (string) $request->query('tab', VMangosAccountService::ACCOUNT_TAB_PLAYERS);
|
||||
|
||||
if (! in_array($activeTab, [AzerothCoreAccountService::ACCOUNT_TAB_PLAYERS, AzerothCoreAccountService::ACCOUNT_TAB_BOTS], true)) {
|
||||
$activeTab = AzerothCoreAccountService::ACCOUNT_TAB_PLAYERS;
|
||||
if (! in_array($activeTab, [VMangosAccountService::ACCOUNT_TAB_PLAYERS, VMangosAccountService::ACCOUNT_TAB_BOTS], true)) {
|
||||
$activeTab = VMangosAccountService::ACCOUNT_TAB_PLAYERS;
|
||||
}
|
||||
|
||||
$accountStats = $accounts->accountTypeStats($searchTerm);
|
||||
@@ -60,13 +60,13 @@ class AccountController extends Controller
|
||||
'accounts' => $accountItems,
|
||||
'accountStats' => $accountStats,
|
||||
'accountTabs' => [
|
||||
AzerothCoreAccountService::ACCOUNT_TAB_PLAYERS => [
|
||||
VMangosAccountService::ACCOUNT_TAB_PLAYERS => [
|
||||
'label' => 'Игроки',
|
||||
'count' => $accountStats[AzerothCoreAccountService::ACCOUNT_TAB_PLAYERS] ?? 0,
|
||||
'count' => $accountStats[VMangosAccountService::ACCOUNT_TAB_PLAYERS] ?? 0,
|
||||
],
|
||||
AzerothCoreAccountService::ACCOUNT_TAB_BOTS => [
|
||||
VMangosAccountService::ACCOUNT_TAB_BOTS => [
|
||||
'label' => 'Боты',
|
||||
'count' => $accountStats[AzerothCoreAccountService::ACCOUNT_TAB_BOTS] ?? 0,
|
||||
'count' => $accountStats[VMangosAccountService::ACCOUNT_TAB_BOTS] ?? 0,
|
||||
],
|
||||
],
|
||||
'activeTab' => $activeTab,
|
||||
@@ -85,7 +85,7 @@ class AccountController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateAccess(int $accountId, UpdateAccountAccessRequest $request, AzerothCoreAccountService $accounts): RedirectResponse
|
||||
public function updateAccess(int $accountId, UpdateAccountAccessRequest $request, VMangosAccountService $accounts): RedirectResponse
|
||||
{
|
||||
abort_unless($accounts->findUserById($accountId), 404);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Http\Controllers\Concerns\BuildsPortalProps;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Admin\AdjustBalanceRequest;
|
||||
use App\Services\AzerothCoreAccountService;
|
||||
use App\Services\VMangosAccountService;
|
||||
use App\Services\BalanceService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -67,7 +67,7 @@ class BalanceController extends Controller
|
||||
|
||||
public function adjust(
|
||||
AdjustBalanceRequest $request,
|
||||
AzerothCoreAccountService $accounts,
|
||||
VMangosAccountService $accounts,
|
||||
BalanceService $balances,
|
||||
): RedirectResponse {
|
||||
$accountInput = trim($request->string('account')->toString());
|
||||
|
||||
@@ -5,29 +5,29 @@ namespace App\Http\Controllers\Api;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\LoginRequest;
|
||||
use App\Models\GameAccount;
|
||||
use App\Services\AzerothCoreAccountService;
|
||||
use App\Services\VMangosAccountService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
class LauncherAuthController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AzerothCoreAccountService $accounts,
|
||||
private readonly VMangosAccountService $accounts,
|
||||
) {
|
||||
}
|
||||
|
||||
#[OA\Post(
|
||||
path: '/api/launcher/login',
|
||||
summary: 'Авторизация лаунчера',
|
||||
description: 'Авторизация по логину и паролю игрового аккаунта. Возвращает Bearer-токен для доступа к API.',
|
||||
description: 'Авторизация по логину и паролю сайта. Возвращает Bearer-токен для доступа к API и выдачи игрового билета.',
|
||||
tags: ['Launcher Auth'],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: true,
|
||||
content: new OA\JsonContent(
|
||||
required: ['username', 'password'],
|
||||
properties: [
|
||||
new OA\Property(property: 'username', type: 'string', minLength: 3, maxLength: 32, pattern: '^[A-Za-z0-9]+$', example: 'Player'),
|
||||
new OA\Property(property: 'password', type: 'string', minLength: 3, maxLength: 32, example: 'secret123'),
|
||||
new OA\Property(property: 'username', type: 'string', minLength: 3, maxLength: 16, pattern: '^[A-Za-z0-9]+$', example: 'Player'),
|
||||
new OA\Property(property: 'password', type: 'string', minLength: 3, maxLength: 16, example: 'secret123'),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -75,7 +75,7 @@ class LauncherAuthController extends Controller
|
||||
], 401);
|
||||
}
|
||||
|
||||
$gameAccount = GameAccount::on('azerothcore_auth')->findOrFail($user->id);
|
||||
$gameAccount = GameAccount::on('vmangos_auth')->findOrFail($user->id);
|
||||
$token = $gameAccount->createToken('launcher');
|
||||
|
||||
return response()->json([
|
||||
|
||||
@@ -211,6 +211,6 @@ class LauncherController extends Controller
|
||||
|
||||
private function basePath(): string
|
||||
{
|
||||
return config('moonwell.launcher.base_path', 'World of Warcraft');
|
||||
return config('moonwell.launcher.base_path', 'World of Warcraft 1.12.1');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,55 +16,41 @@ class LauncherGameTicketController extends Controller
|
||||
|
||||
#[OA\Post(
|
||||
path: '/api/launcher/game-ticket',
|
||||
summary: 'Issue a single-use game login ticket',
|
||||
description: 'Creates short-lived SRP credentials for authserver. A new ticket atomically revokes the previous generation. The plaintext ticket is never stored.',
|
||||
summary: 'Выдать одноразовый билет для входа в vMaNGOS',
|
||||
description: 'Создаёт короткоживущий SRP-билет. Новый билет отзывает предыдущий.',
|
||||
security: [['bearerAuth' => []]],
|
||||
tags: ['Launcher Auth'],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: true,
|
||||
content: new OA\JsonContent(
|
||||
required: ['client_build'],
|
||||
properties: [
|
||||
new OA\Property(property: 'client_build', type: 'integer', example: 12340),
|
||||
],
|
||||
),
|
||||
),
|
||||
requestBody: new OA\RequestBody(required: true, content: new OA\JsonContent(
|
||||
required: ['client_build'],
|
||||
properties: [new OA\Property(property: 'client_build', type: 'integer', example: 5875)],
|
||||
)),
|
||||
responses: [
|
||||
new OA\Response(
|
||||
response: 200,
|
||||
description: 'Ticket issued',
|
||||
content: new OA\JsonContent(
|
||||
required: ['account', 'ticket', 'expires_at'],
|
||||
properties: [
|
||||
new OA\Property(property: 'account', type: 'string', example: 'PLAYERONE'),
|
||||
new OA\Property(property: 'ticket', type: 'string', pattern: '^[A-Z0-9]{16}$', example: '7W6D4M2Q9K8R3X5Z'),
|
||||
new OA\Property(property: 'expires_at', type: 'string', format: 'date-time'),
|
||||
],
|
||||
),
|
||||
),
|
||||
new OA\Response(response: 200, description: 'Билет выдан', content: new OA\JsonContent(
|
||||
required: ['account', 'ticket', 'expires_at'],
|
||||
properties: [
|
||||
new OA\Property(property: 'account', type: 'string', example: 'PLAYERONE'),
|
||||
new OA\Property(property: 'ticket', type: 'string', pattern: '^[A-Z0-9]{16}$'),
|
||||
new OA\Property(property: 'expires_at', type: 'string', format: 'date-time'),
|
||||
],
|
||||
)),
|
||||
new OA\Response(response: 401, description: 'Launcher authentication required'),
|
||||
new OA\Response(response: 422, description: 'Client build is not allowed'),
|
||||
new OA\Response(response: 422, description: 'Unsupported client build'),
|
||||
new OA\Response(response: 429, description: 'Too many requests'),
|
||||
],
|
||||
)]
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$clientBuild = (int) $request->validate([
|
||||
'client_build' => [
|
||||
'required',
|
||||
'integer',
|
||||
Rule::in([(int) config('moonwell.launcher.client_build', 12340)]),
|
||||
],
|
||||
$build = (int) $request->validate([
|
||||
'client_build' => ['required', 'integer', Rule::in([(int) config('moonwell.launcher.client_build')])],
|
||||
])['client_build'];
|
||||
|
||||
/** @var GameAccount $account */
|
||||
$account = $request->user();
|
||||
$launcherSessionToken = $request->bearerToken();
|
||||
|
||||
abort_if($launcherSessionToken === null, 401);
|
||||
$bearer = $request->bearerToken();
|
||||
abort_if($bearer === null, 401);
|
||||
|
||||
return response()
|
||||
->json($this->tickets->issue($account, $launcherSessionToken, $clientBuild))
|
||||
->json($this->tickets->issue($account, $bearer, $build))
|
||||
->header('Cache-Control', 'no-store');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Exceptions\DuplicateGameAccountException;
|
||||
use App\Exceptions\InviteCodeException;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\RegisterGameAccountRequest;
|
||||
use App\Services\AzerothCoreAccountRegistrar;
|
||||
use App\Services\VMangosAccountRegistrar;
|
||||
use App\Services\InviteCodeService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use OpenApi\Attributes as OA;
|
||||
@@ -17,18 +17,18 @@ class LauncherRegistrationController extends Controller
|
||||
#[OA\Post(
|
||||
path: '/api/launcher/register',
|
||||
summary: 'Зарегистрировать игровой аккаунт',
|
||||
description: 'Создаёт игровой аккаунт AzerothCore. Инвайт-код обязателен, если на сервере включена регистрация по приглашениям.',
|
||||
description: 'Создаёт аккаунт сайта и vMaNGOS со случайным игровым паролем. Для входа в игру лаунчер выдаёт билет. Инвайт-код обязателен, если включена регистрация по приглашениям.',
|
||||
tags: ['Launcher Auth'],
|
||||
requestBody: new OA\RequestBody(
|
||||
required: true,
|
||||
content: new OA\JsonContent(
|
||||
required: ['username', 'email', 'password', 'password_confirmation', 'terms'],
|
||||
properties: [
|
||||
new OA\Property(property: 'username', type: 'string', minLength: 3, maxLength: 32, pattern: '^[A-Za-z0-9]+$', example: 'Player'),
|
||||
new OA\Property(property: 'username', type: 'string', minLength: 3, maxLength: 16, pattern: '^[A-Za-z0-9]+$', example: 'Player'),
|
||||
new OA\Property(property: 'email', type: 'string', format: 'email', maxLength: 255, example: 'player@example.com'),
|
||||
new OA\Property(property: 'invite_code', type: 'string', minLength: 6, maxLength: 32, nullable: true, example: 'ABCD-EFGH-IJKL'),
|
||||
new OA\Property(property: 'password', type: 'string', minLength: 8, maxLength: 32, example: 'Secret123'),
|
||||
new OA\Property(property: 'password_confirmation', type: 'string', minLength: 8, maxLength: 32, example: 'Secret123'),
|
||||
new OA\Property(property: 'password', type: 'string', minLength: 8, maxLength: 16, example: 'Secret123'),
|
||||
new OA\Property(property: 'password_confirmation', type: 'string', minLength: 8, maxLength: 16, example: 'Secret123'),
|
||||
new OA\Property(property: 'terms', type: 'boolean', example: true, description: 'Согласие с правилами сервера и пользовательским соглашением'),
|
||||
],
|
||||
),
|
||||
@@ -82,7 +82,7 @@ class LauncherRegistrationController extends Controller
|
||||
)]
|
||||
public function store(
|
||||
RegisterGameAccountRequest $request,
|
||||
AzerothCoreAccountRegistrar $registrar,
|
||||
VMangosAccountRegistrar $registrar,
|
||||
InviteCodeService $inviteCodes,
|
||||
): JsonResponse {
|
||||
try {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ChangePasswordRequest;
|
||||
use App\Services\AzerothCoreAccountService;
|
||||
use App\Services\VMangosAccountService;
|
||||
use App\Services\BalanceService;
|
||||
use App\Services\GameClientDownloadService;
|
||||
use App\Services\StoreAvailabilityService;
|
||||
@@ -17,7 +17,7 @@ class CabinetController extends Controller
|
||||
{
|
||||
public function index(
|
||||
Request $request,
|
||||
AzerothCoreAccountService $accounts,
|
||||
VMangosAccountService $accounts,
|
||||
BalanceService $balances,
|
||||
StoreAvailabilityService $storeAvailability,
|
||||
): Response
|
||||
@@ -83,7 +83,7 @@ class CabinetController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function updatePassword(ChangePasswordRequest $request, AzerothCoreAccountService $accounts): RedirectResponse
|
||||
public function updatePassword(ChangePasswordRequest $request, VMangosAccountService $accounts): RedirectResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ use App\Exceptions\DuplicateGameAccountException;
|
||||
use App\Exceptions\InviteCodeException;
|
||||
use App\Http\Requests\RegisterGameAccountRequest;
|
||||
use App\Models\News;
|
||||
use App\Services\AzerothCoreAccountRegistrar;
|
||||
use App\Services\AzerothCoreAccountService;
|
||||
use App\Services\VMangosAccountRegistrar;
|
||||
use App\Services\VMangosAccountService;
|
||||
use App\Services\InviteCodeService;
|
||||
use App\Services\NewsService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -22,7 +22,7 @@ class LandingController extends Controller
|
||||
{
|
||||
public function index(
|
||||
Request $request,
|
||||
AzerothCoreAccountService $accounts,
|
||||
VMangosAccountService $accounts,
|
||||
NewsService $news,
|
||||
): Response {
|
||||
$realmConfig = config('moonwell.realm');
|
||||
@@ -68,7 +68,7 @@ class LandingController extends Controller
|
||||
'ping' => 38,
|
||||
'factions' => ['alliance' => 52, 'horde' => 48],
|
||||
'rates' => $rates,
|
||||
'client_version' => $realmConfig['client_version'] ?? '3.3.5a',
|
||||
'client_version' => $realmConfig['client_version'] ?? '1.12.1',
|
||||
'tagline' => $realmConfig['tagline'] ?? null,
|
||||
'server_name' => $serverName,
|
||||
],
|
||||
@@ -112,7 +112,7 @@ class LandingController extends Controller
|
||||
|
||||
public function register(
|
||||
RegisterGameAccountRequest $request,
|
||||
AzerothCoreAccountRegistrar $registrar,
|
||||
VMangosAccountRegistrar $registrar,
|
||||
InviteCodeService $inviteCodes,
|
||||
): RedirectResponse {
|
||||
try {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\News;
|
||||
use App\Services\AzerothCoreAccountService;
|
||||
use App\Services\VMangosAccountService;
|
||||
use App\Services\NewsService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -16,7 +16,7 @@ class MainController extends Controller
|
||||
{
|
||||
public function index(
|
||||
Request $request,
|
||||
AzerothCoreAccountService $accounts,
|
||||
VMangosAccountService $accounts,
|
||||
NewsService $news,
|
||||
): Response
|
||||
{
|
||||
@@ -56,7 +56,7 @@ class MainController extends Controller
|
||||
'ping' => 38,
|
||||
'factions' => ['alliance' => 52, 'horde' => 48],
|
||||
'rates' => $rates,
|
||||
'client_version' => $realmConfig['client_version'] ?? '3.3.5a',
|
||||
'client_version' => $realmConfig['client_version'] ?? '1.12.1',
|
||||
'tagline' => $realmConfig['tagline'] ?? null,
|
||||
'server_name' => $realmConfig['server_name'] ?? 'MoonWell',
|
||||
],
|
||||
|
||||
@@ -17,8 +17,8 @@ class ChangePasswordRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'current_password' => ['required', 'string', 'max:32'],
|
||||
'password' => ['required', 'string', 'min:8', 'max:32', 'confirmed', 'regex:/^(?=.*[A-Za-z])(?=.*\d).+$/'],
|
||||
'current_password' => ['required', 'string', 'max:16'],
|
||||
'password' => ['required', 'string', 'min:8', 'max:16', 'confirmed', 'regex:/^(?=.*[A-Za-z])(?=.*\d).+$/'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ class ChangePasswordRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'current_password.required' => 'Укажи текущий пароль.',
|
||||
'current_password.max' => 'Текущий пароль не должен быть длиннее 32 символов.',
|
||||
'current_password.max' => 'Текущий пароль не должен быть длиннее 16 символов.',
|
||||
'password.required' => 'Укажи новый пароль.',
|
||||
'password.min' => 'Новый пароль должен содержать минимум 8 символов.',
|
||||
'password.max' => 'Новый пароль не должен быть длиннее 32 символов.',
|
||||
'password.max' => 'Новый пароль не должен быть длиннее 16 символов.',
|
||||
'password.confirmed' => 'Подтверждение нового пароля не совпадает.',
|
||||
'password.regex' => 'Новый пароль должен содержать хотя бы одну букву и одну цифру.',
|
||||
];
|
||||
|
||||
@@ -17,8 +17,8 @@ class LoginRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'username' => ['required', 'string', 'min:3', 'max:32', 'regex:/^[A-Za-z0-9]+$/'],
|
||||
'password' => ['required', 'string', 'min:3', 'max:32'],
|
||||
'username' => ['required', 'string', 'min:3', 'max:16', 'regex:/^[A-Za-z0-9]+$/'],
|
||||
'password' => ['required', 'string', 'min:3', 'max:16'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ class LoginRequest extends FormRequest
|
||||
return [
|
||||
'username.required' => 'Укажи логин аккаунта.',
|
||||
'username.min' => 'Логин должен содержать минимум 3 символа.',
|
||||
'username.max' => 'Логин не должен быть длиннее 32 символов.',
|
||||
'username.max' => 'Логин не должен быть длиннее 16 символов.',
|
||||
'username.regex' => 'Логин может содержать только латинские буквы и цифры.',
|
||||
'password.required' => 'Укажи пароль.',
|
||||
'password.min' => 'Пароль должен содержать минимум 3 символа.',
|
||||
'password.max' => 'Пароль не должен быть длиннее 32 символов.',
|
||||
'password.max' => 'Пароль не должен быть длиннее 16 символов.',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ class RegisterGameAccountRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'username' => ['required', 'string', 'min:3', 'max:32', 'regex:/^[A-Za-z0-9]+$/'],
|
||||
'username' => ['required', 'string', 'min:3', 'max:16', 'regex:/^[A-Za-z0-9]+$/'],
|
||||
'email' => ['required', 'string', 'email:rfc', 'max:255'],
|
||||
'invite_code' => [config('moonwell.registration.require_invite_code') ? 'required' : 'nullable', 'string', 'min:6', 'max:32'],
|
||||
'password' => ['required', 'string', 'min:8', 'max:32', 'confirmed', 'regex:/^(?=.*[A-Za-z])(?=.*\d).+$/'],
|
||||
'password' => ['required', 'string', 'min:8', 'max:16', 'confirmed', 'regex:/^(?=.*[A-Za-z])(?=.*\d).+$/'],
|
||||
'terms' => ['accepted'],
|
||||
];
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class RegisterGameAccountRequest extends FormRequest
|
||||
'username.required' => 'Укажи логин аккаунта.',
|
||||
'username.string' => 'Логин должен быть строкой.',
|
||||
'username.min' => 'Логин должен содержать минимум 3 символа.',
|
||||
'username.max' => 'Логин не должен быть длиннее 32 символов.',
|
||||
'username.max' => 'Логин не должен быть длиннее 16 символов.',
|
||||
'username.regex' => 'Логин может содержать только латинские буквы и цифры.',
|
||||
'email.required' => 'Укажи email для аккаунта.',
|
||||
'email.string' => 'Email должен быть строкой.',
|
||||
@@ -47,7 +47,7 @@ class RegisterGameAccountRequest extends FormRequest
|
||||
'password.required' => 'Укажи пароль.',
|
||||
'password.string' => 'Пароль должен быть строкой.',
|
||||
'password.min' => 'Пароль должен содержать минимум 8 символов.',
|
||||
'password.max' => 'Пароль не должен быть длиннее 32 символов.',
|
||||
'password.max' => 'Пароль не должен быть длиннее 16 символов.',
|
||||
'password.confirmed' => 'Подтверждение пароля не совпадает.',
|
||||
'password.regex' => 'Пароль должен содержать хотя бы одну букву и одну цифру.',
|
||||
'terms.accepted' => 'Нужно принять правила сервера и пользовательское соглашение.',
|
||||
|
||||
Reference in New Issue
Block a user