Skip to content

[Security] Voters: What's the advantage over doing it in the controller? #13406

Closed
@ThomasLandauer

Description

@ThomasLandauer

The entire example used throughout https://symfony.com/doc/4.4/security/voters.html (namely checking if a certain user is allowed to edit this specific post) can be achieved with 2 lines in the "edit"-Controller:

if ($post->getOwner() !== $this->getUser()) {
    throw new AccessDeniedException();
}

So what's the advantage of setting up this complicated voting system?? This should be explained on the page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions