Check user login and has permission

edited October 2013 in Share
I want to check in each controller
--is login required or not
--is user logged in or not
--is has permission for the requested controller method.

Actually I want to make controller permission system.
how it is possible.

Please help me.


  • edited 3:17AM
    In the 1.0 beta, If you inherit from the Fuel_base_controller, there is a protected "_validate_user" method you can use which will validate if a person is logged in by using the Fuel_auth class (e.g. $this->fuel->auth->has_permission($permission)). By default, a controller inheriting from Fuel_base_controller will run that method unless you pass FALSE to the parent constructor.
  • How can i call fuel_base_controller class
    if i user

    Class ufcm extends Fuel_base_controller{


    then i is

    Fatal error: Class 'fuel_base_controller' not found in D:\xampp\htdocs\ufcm\fuel\modules\ufcm\controllers\ufcm.php on line 3


    I want to use login and permission checker in pre_controller hook CI function. SO please tell me how can i do that
  • edited 3:17AM
    Add the following at the top of your controller:

    To add a hook, you can add to the fuel/application/config/hooks.php file like any other CI hook.
  • Hi
    after a long vacation I have come back.

    I used your code, its working. I need to know that

    How to set access permission like model page access permission ?
  • edited 3:17AM
    If you use the CLI generation tool in 1.0, it will automatically generate permissions for you:

    If you don't use the generate tool, in 1.0 you normally create 5 different permissions. An overall permission, one for create, one for edit, one for publish and another for delete. Below is a SQL insert as an example. This can all be done with the permissions module and there are checkboxes to automatically generate those additional create, edit, publish and delete permissions.

    INSERT INTO `fuel_permissions` (`id`, `description`, `name`, `active`)
    (NULL, 'Events', 'events', 'yes'),
    (NULL, 'Events: Create', 'events/create', 'yes'),
    (NULL, 'Events: Edit', 'events/edit', 'yes'),
    (NULL, 'Events: Publish', 'events/publish', 'yes'),
    (NULL, 'Events: Delete', 'events/delete', 'yes');
Sign In or Register to comment.