Skip to content

Commit

Permalink
When form is inactive returns code 400 and event YupFormSubmissionRej…
Browse files Browse the repository at this point in the history
…ected
  • Loading branch information
ser-gi-o committed May 30, 2022
1 parent a9550b9 commit 9d83883
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Http/YupFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,28 +239,31 @@ public function submit($publicId)
} else {
//check form restrictions
if (!$yupForm->isActive()) {
$response['message'] = "Not Found ($publicId)";
$note = "Inactive ($publicId)";
event(new YupFormSubmissionRejected($formData, $serverData, $response['message']));

} elseif ($yupForm->hasHost()) {
//$requestHost = request()->headers->get('origin')
$requestHost = request()->server('HTTP_ORIGIN');

if (!$yupForm->isValidHost($requestHost)) {
$note = 'Invalid Host: ' . $requestHost;
$response['message'] = "Not Found ($publicId)";
event(new YupFormSubmissionRejected($formData, $serverData, $response['message']));
}
} else {
$response['error'] = 0;
$response['code'] = 200;

$yupFormData = $yupForm->storeSubmission(
$formData,
$serverData,
$response['error'],
$note
);
event(new YupFormSubmissionAccepted($yupFormData));
}

$response['code'] = 200;

$yupFormData = $yupForm->storeSubmission(
$formData,
$serverData,
$response['error'],
$note
);
event(new YupFormSubmissionAccepted($yupFormData));
}

if ($ajaxRequest) {
Expand Down

0 comments on commit 9d83883

Please sign in to comment.