Description
Description
isGranted()
assumes that it's checking against the currently logged in user. It would be great to be able to use something similar to check against another user or during times when there isn't a session (cronjobs/commands, message queue, etc.).
I would see this as a userIsGranted()
function to make a distinction. There's cases we'd have to consider, such as if IS_AUTHENTICATED_*
is used in conjunction with this method, as those are based on sessions. Return false, or throw a logic exception, etc.
Having this functionality would allow for removing the dependency on sessions entirely for services reducing the number of issues that come up during a project because some underlying function was session dependent.
I'm assuming we'd also want to create a new Token class to represent checking against a non-logged in user.
Example
Checking to see if you could assign another user to review an article:
$security->userIsGranted($reviewer, ArticleVoter::REVIEW, $article);