I
I
Ivan Antonov2016-04-04 13:02:07
symfony
Ivan Antonov, 2016-04-04 13:02:07

How can annotations check if the user is the owner when going to editAction?

There is such an Action in the controller:

/**
     * Displays a form to edit an existing Offer entity.
     *
     * @Route("/{id}/edit", name="offer_edit")
     * @Method({"GET", "POST"})
     * @Security("has_role('ROLE_USER')")
     */
    public function editAction(Request $request, Offer $offer)
    { // ...

As you can see now there is a check only for an authorized user.
Is it possible to specify the condition of ownership of the Offer through and, if so, how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2016-04-04
@antonowano

@Security

/**
 * @Security("is_granted('OFFER_OWNER', offer) and has_role('ROLE_USER')"")
 */
public function editAction(Request $request, Offer $offer)
{
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question