админка
This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Exceptions\DuplicateGameAccountException;
|
||||
use App\Exceptions\InviteCodeException;
|
||||
use App\Http\Requests\RegisterGameAccountRequest;
|
||||
use App\Services\AzerothCoreAccountRegistrar;
|
||||
use App\Services\InviteCodeService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\View\View;
|
||||
use Throwable;
|
||||
@@ -85,24 +87,36 @@ class LandingController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function register(RegisterGameAccountRequest $request, AzerothCoreAccountRegistrar $registrar): RedirectResponse
|
||||
public function register(
|
||||
RegisterGameAccountRequest $request,
|
||||
AzerothCoreAccountRegistrar $registrar,
|
||||
InviteCodeService $inviteCodes,
|
||||
): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$result = $registrar->register(
|
||||
$result = $inviteCodes->redeemForRegistration(
|
||||
$request->string('invite_code')->toString(),
|
||||
$request->string('username')->toString(),
|
||||
$request->string('email')->toString(),
|
||||
$request->string('password')->toString(),
|
||||
fn (): array => $registrar->register(
|
||||
$request->string('username')->toString(),
|
||||
$request->string('email')->toString(),
|
||||
$request->string('password')->toString(),
|
||||
),
|
||||
);
|
||||
} catch (DuplicateGameAccountException $exception) {
|
||||
return back()
|
||||
->withErrors([$exception->field => $exception->getMessage()])
|
||||
->withInput($request->safe()->only(['username', 'email']));
|
||||
->withInput($request->safe()->only(['username', 'email', 'invite_code']));
|
||||
} catch (InviteCodeException $exception) {
|
||||
return back()
|
||||
->withErrors([$exception->field => $exception->getMessage()])
|
||||
->withInput($request->safe()->only(['username', 'email', 'invite_code']));
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
|
||||
return back()
|
||||
->with('registration_error', 'Не удалось создать аккаунт. Проверь настройки сервера и попробуй снова.')
|
||||
->withInput($request->safe()->only(['username', 'email']));
|
||||
->withInput($request->safe()->only(['username', 'email', 'invite_code']));
|
||||
}
|
||||
|
||||
return redirect()
|
||||
|
||||
Reference in New Issue
Block a user