Skip to content
Snippets Groups Projects
Commit 22dc81fe authored by Stefan Galinski's avatar Stefan Galinski :video_game:
Browse files

[BUGFIX] Fix some issues with the validation

parent c1df03ab
No related branches found
No related tags found
No related merge requests found
...@@ -109,16 +109,24 @@ class JoblistController extends ActionController { ...@@ -109,16 +109,24 @@ class JoblistController extends ActionController {
* *
* @param JobApplication $applyData * @param JobApplication $applyData
* @param string $error * @param string $error
* @param string $folderName
* @param int $uid * @param int $uid
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException
*/ */
public function applyFormAction(JobApplication $applyData = NULL, $error = NULL, $folderName = NULL, $uid = NULL) { public function applyFormAction(JobApplication $applyData = NULL, $error = NULL, $uid = NULL) {
if ($error !== NULL && $error !== '') { if ($error !== NULL && $error !== '') {
$this->view->assign('internalError', $error); $this->view->assign('internalError', $error);
$this->request->setArgument('error', NULL);
} }
$folderName = NULL;
try {
$folderName = $this->request->getArgument('folderName');
} catch (\Exception $exception) {
// nope
}
if ($folderName === NULL) { if ($folderName === NULL) {
$folderName = md5(uniqid('sgjobs-', TRUE)); $folderName = md5(uniqid('sgjobs-', TRUE));
$this->request->setArgument('folderName', $folderName);
} }
$this->view->assign('folderName', $folderName); $this->view->assign('folderName', $folderName);
...@@ -157,13 +165,15 @@ class JoblistController extends ActionController { ...@@ -157,13 +165,15 @@ class JoblistController extends ActionController {
* @return void * @return void
* @throws NoSuchArgumentException * @throws NoSuchArgumentException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException * @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/ */
protected function initializeApplyAction() { protected function initializeApplyAction() {
try { try {
$uniqueFolderName = $this->request->getArgument('folderName'); $uniqueFolderName = $this->request->getArgument('folderName');
} catch (NoSuchArgumentException $exception) { } catch (NoSuchArgumentException $exception) {
$exceptionMessage = 'Eine Datei konnte nicht hochgeladen werden. Ist diese eventuell zu groß?'; $exceptionMessage = 'Eine Datei konnte nicht hochgeladen werden. Ist diese eventuell zu groß?';
$this->forward('applyForm', NULL, NULL, ['error' => $exceptionMessage]); $this->redirect('applyForm', NULL, NULL, ['error' => $exceptionMessage]);
exit;
} }
$propertyMappingConfiguration = $this->arguments->getArgument('applyData')->getPropertyMappingConfiguration(); $propertyMappingConfiguration = $this->arguments->getArgument('applyData')->getPropertyMappingConfiguration();
......
...@@ -125,19 +125,19 @@ class JobApplication extends AbstractEntity { ...@@ -125,19 +125,19 @@ class JobApplication extends AbstractEntity {
/** /**
* @var \SGalinski\SgJobs\Domain\Model\FileReference $coverLetter * @var \SGalinski\SgJobs\Domain\Model\FileReference $coverLetter
* * @validate NotEmpty
*/ */
protected $coverLetter; protected $coverLetter;
/** /**
* @var \SGalinski\SgJobs\Domain\Model\FileReference $cv * @var \SGalinski\SgJobs\Domain\Model\FileReference $cv
* * @validate NotEmpty
*/ */
protected $cv; protected $cv;
/** /**
* @var \SGalinski\SgJobs\Domain\Model\FileReference $certificate * @var \SGalinski\SgJobs\Domain\Model\FileReference $certificate
* * @validate NotEmpty
*/ */
protected $certificate; protected $certificate;
......
...@@ -328,7 +328,7 @@ class UploadedFileReferenceConverter implements TypeConverterInterface { ...@@ -328,7 +328,7 @@ class UploadedFileReferenceConverter implements TypeConverterInterface {
* Import a resource and respect configuration given for properties * Import a resource and respect configuration given for properties
* *
* @param array $uploadInfo * @param array $uploadInfo
* @return \SGalinski\SgJobs\Domain\Model\FileReference * @return \SGalinski\SgJobs\Domain\Model\FileReference|NULL
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @throws TypeConverterException * @throws TypeConverterException
* @throws \Exception * @throws \Exception
...@@ -336,7 +336,8 @@ class UploadedFileReferenceConverter implements TypeConverterInterface { ...@@ -336,7 +336,8 @@ class UploadedFileReferenceConverter implements TypeConverterInterface {
* @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException * @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
* @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException * @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException
*/ */
protected function importUploadedResource(array $uploadInfo): FileReference { protected function importUploadedResource(array $uploadInfo) {
$uploadedFile = NULL;
$filePathInfo = PathUtility::pathinfo($uploadInfo['name']); $filePathInfo = PathUtility::pathinfo($uploadInfo['name']);
$fileName = $this->getTargetUploadFileName(); $fileName = $this->getTargetUploadFileName();
$finalFileName = $fileName . '.' . strtolower($filePathInfo['extension']); $finalFileName = $fileName . '.' . strtolower($filePathInfo['extension']);
...@@ -372,6 +373,7 @@ class UploadedFileReferenceConverter implements TypeConverterInterface { ...@@ -372,6 +373,7 @@ class UploadedFileReferenceConverter implements TypeConverterInterface {
$uploadFolderId = $this->getUploadFolder(); $uploadFolderId = $this->getUploadFolder();
// Security protection to not allow manipulations outside of this specific folder // Security protection to not allow manipulations outside of this specific folder
if (strpos($uploadFolderId, '/JobApplication/') !== FALSE) { if (strpos($uploadFolderId, '/JobApplication/') !== FALSE) {
debug($uploadFolderId . '/' . $finalFileName);
try { try {
$uploadedFile = $this->resourceFactory->retrieveFileOrFolderObject( $uploadedFile = $this->resourceFactory->retrieveFileOrFolderObject(
$uploadFolderId . '/' . $finalFileName $uploadFolderId . '/' . $finalFileName
...@@ -385,6 +387,10 @@ class UploadedFileReferenceConverter implements TypeConverterInterface { ...@@ -385,6 +387,10 @@ class UploadedFileReferenceConverter implements TypeConverterInterface {
} }
} }
if (!$uploadedFile) {
return NULL;
}
return $this->createFileReferenceFromFalFileObject($uploadedFile); return $this->createFileReferenceFromFalFileObject($uploadedFile);
} }
......
...@@ -31,12 +31,11 @@ ...@@ -31,12 +31,11 @@
</f:if> </f:if>
<f:if condition="{job}"> <f:if condition="{job}">
<p> <div>
<f:form.hidden name="jobId" value="{job.jobId}" /> <f:form.hidden name="jobId" value="{job.jobId}" />
<f:form.hidden property="jobTitle" value="{job.title}" /> <f:form.hidden property="jobTitle" value="{job.title}" />
<label for="apply-title"><f:translate key="frontend.apply.title" /></label> <h1>Bewerbung für <span id="apply-title">{job.title}</span></h1>
<span id="apply-title">{job.title}</span> </div>
</p>
</f:if> </f:if>
<p> <p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment