throw 403 error instead of 422 and display toast message

This commit is contained in:
2022-02-25 13:11:30 +01:00
parent 68bfca8a1f
commit 16cca07e12
7 changed files with 17 additions and 44 deletions

View File

@@ -18,9 +18,6 @@ use Symfony\Component\Validator\Constraint;
*/
class AccompanyingPeriodValidity extends Constraint
{
public $messageReferrerIsCurrentUser = 'Only the referrer can change the confidentiality of a parcours';
public $messageReferrerIsNull = 'A confidential parcours must have a referrer';
public $messageSocialIssueCannotBeDeleted = 'The social %name% issue cannot be deleted because it is associated with an activity or an action';

View File

@@ -92,19 +92,5 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator
->addViolation();
}
}
/** Check if confidentiality can be toggled */
$user = $period->getUser();
$currentUser = $this->token->getToken()->getUser();
if ($user && ($user !== $currentUser) && $period->isConfidential() === true) {
$this->context->buildViolation($constraint->messageReferrerIsCurrentUser)
->addViolation();
}
if (null === $user && $period->isConfidential() === true) {
$this->context->buildViolation($constraint->messageReferrerIsNull)
->addViolation();
}
}
}