Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Best way to handle admin section authentication?
  • I've searched the forums for this, but none of the posts seemed to have a definitive answer. I'm wondering what is the best way to handle authentication checks for an admin section that is using different controller types ie: template and rest. The only way I really see it possible without having to do the check in every controller is to make a new base admin controller for each type.. like Controller_AdminTemplate extends Controller_Template and Controller_AdminRest extends Controller_Rest. Then I would do the auth check in those and all the other admin controllers would extend them as needed. Is this the best way of going about this, or has someone found a better way? Just looking for input.
  • Controller_Base extends Controller_Template
    Controller_Admin extends Controller_Base
    Controller_Public extends Controller_Base Set all your logic in them, function before() with parent::before();
  • That would be a good way to go about it. Just make a Controller_Base class and add Auth::check in a before method. Don't forget parent::before() in inheriting classes.
  • Thanks for the tip Phil. I'm going through and tearing apart PyroCMS and really like how you did it there. Don't know how common it is to use admin routing the way you did with modules, but that's just ingenious - never imagined routing could be that powerful.

Howdy, Stranger!

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

In this Discussion