Answer the question
In order to leave comments, you need to log in
How to resolve the issue with getting access denied reason text when using CustomVoter and IsGranted()?
Hello.
Voter returns ACCESS_GRANTED or ACCESS_DENIED in cases where access is allowed or denied, respectively, but the check for access permission is complex, i.e. factors that influence the decision-making are not always single, for example: you want to pay for the goods, but you are denied access, and in fact, the reasons for the refusal may be different, either "The account is blocked", or the account is not blocked, but "There are not enough funds for account". And I would like to receive specific error messages due to which access was denied in order to display to the user in the controller.
Is it appropriate to write errors to a special service that will be called in Voter when access is denied, or use a static class?
Or maybe use a trait that will work with a static class and implement this trait in Voters ?
Answer the question
In order to leave comments, you need to log in
Account blocked
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question