Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
The best way to send a 403 from the before() method
  • Hi all, I have some code to detect a logged-in-user's permissions, I want to display a 403 page in a similar way to a \Request::show_404(); Is there a built in way of doing this? How have you implemented this in your project? All the best
    Rob McCann :)
  • To anyone wondering about this, I now extend the HTTP status classes from the core in my app/classes folder and do all my processing there rather than in action_404 or action_403
  • Better way might have been to implement a router() method in your controller and do this type of processing there. before() isn't intended to perform any routing-like functionality (including generating responses), the before() method is just there to set everything up you need when the action method is executed. The after() method is meant to post-process the response once generated by the controller. Setting the response status code is part of routing logic as it involves generating a response, thus it belongs in a router() method.
  • Have you looked at this page in the docs? http://fuelphp.com/docs/classes/response.html
  • yep :) The problem arises that it still calls my action_*() functions even if I set a 403 header in the before class. Rob

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion