Skip to content
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

Accepting a table without valid registration results in server error #77

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion app/Http/Controllers/TableVerifyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,28 @@ public function update(Request $request)
$user = Auth::user();
/** @var Application */
$application = $user->application;
/** @var null|string */
$registrationId = $user->reg_id;

abort_if(empty($application), 404, 'Application not found.');
abort_if($application->status !== ApplicationStatus::TableOffered, 403, 'No table offer available to be accepted.');
abort_if($application->type !== ApplicationType::Dealer, 403, 'Shares and Assistants cannot manage this.');

if (!$registrationId && $registrationId = RegSysClientController::getRegistrationIdForCurrentUser()) {
$user->update(['reg_id' => $registrationId]);
}

$registration = $registrationId ? RegSysClientController::getSingleReg($registrationId) : null;

if ($registration === null) {
return Redirect::route('table.confirm')->with('table-confirmation-registration-not-found');
} elseif ($registration['status'] === 'cancelled' || $registration['status'] === 'new') {
return Redirect::route('table.confirm')->with('table-confirmation-registration-inactive');
}

$assignedTable = $application->assignedTable()->first();

if (RegSysClientController::bookPackage(Auth::user()->reg_id, $assignedTable)) {
if (RegSysClientController::bookPackage($registrationId, $assignedTable)) {
$application->setStatusAttribute(ApplicationStatus::TableAccepted);
$user->notify(new TableAcceptedNotification($assignedTable->name, $application->table_number, $assignedTable->price));
foreach ($application->children()->get() as $child) {
Expand Down
2 changes: 1 addition & 1 deletion resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<p>Your registration as a dealer was accepted! Please review and accept the table you were
offered.
</p>
<a href="{{ route('table.confirm') }}" class="btn btn-lg btn-primary">Review Offered Table</a>
<p><a href="{{ route('table.confirm') }}" class="btn btn-lg btn-primary">Review Offered Table</a></p>
@else
<h3>Congratulations!</h3>
<p>The application of the dealership you are part of was accepted! The main account of your
Expand Down
11 changes: 11 additions & 0 deletions resources/views/table/confirm.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
<div class="alert alert-danger text-center fw-bold">An error has occurred, please try again. If the error
persists, please get in touch with the Dealer's Den team at <a
href="mailto:{{ config('con.dealers_email') }}">{{ config('con.dealers_email') }}</a></div>
@elseif (Session::exists('table-confirmation-registration-not-found'))
<div class="alert alert-danger text-center fw-bold">We were unable to find your Eurofurence registration, which
is a mandatory prerequisite for accepting a table at the Dealers' Den. If you have already
registered for the convention, but the error persists, please get in touch with the Dealer's Den team at <a
href="mailto:{{ config('con.dealers_email') }}">{{ config('con.dealers_email') }}</a></div>
@elseif (Session::exists('table-confirmation-registration-inactive'))
<div class="alert alert-danger text-center fw-bold">Your registration for Eurofurence seems to be inactive, but
accepting a table at the Dealers' Den requires an active registration for event itself. Please check
that your registration for the convention has been confirmed and has not been canceled, otherwise please get in
touch with the Dealer's Den team at <a
href="mailto:{{ config('con.dealers_email') }}">{{ config('con.dealers_email') }}</a></div>
@endif

@if ($application->status === \App\Enums\ApplicationStatus::TableOffered)
Expand Down
Loading