Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Auth Permissions - Why are these hard coded in here?
  • These 3 little lines of code really frustrated me today.  Why are these hard coded in here?

    Perhaps have them in driver.config or something?


    Line: 146-148

    static::$_many_many['users']['table_through'] = \Config::get('ormauth.table_name', 'users').'_user_permissions';
    static::$_many_many['groups']['table_through'] = \Config::get('ormauth.table_name', 'users').'_group_permissions';
    static::$_many_many['roles']['table_through'] = \Config::get('ormauth.table_name', 'users').'_role_permissions';
  • It might be to prevent you trying to do things the system is not designed for.

    Have you tried extending the package so you can change the code to pull the hard-coded values from the config?

    These threads go into how to do this, maybe it will help

  • Actually the system was designed to do this.  :)  

    I just needed to explore the code more and I was defining some things a little too early and it was being overwritten somewhere else. (I also posted that after spending a few hours being VERY frustrated until I figured it out).  :)

    But also good to have it in here for the next guy. 

    And Yes, I have extended every model and wrote all the drivers specific for my existing data models and authentication methods.  :) I am plugging fuel into an existing product. As much as I would have loved to replace everything with Fuel's default OrmAuth and Auth Models, it is not an option.

    The issue was that I was not overwriting the many to many relationships.

    And I did not realize that those tables were defined again in _init.

    The best solution in my opinion is to simply overwrite all the relationships in the extended models _initi and after calling parent::_init and set the 'table_through' in the many to many relationships.


    * @var array many_many relationships
    static::$_many_many = array(
    'roles' => array(
    'key_from' => 'id',
    'model_to' => '\\Model\\Auth_Role',
    'key_to' => 'id',
    'table_through' => 'USER_USER_ROLES',
    'key_through_from' => 'user_id',
    'key_through_to' => 'role_id',
    'permissions' => array(
    'key_from' => 'id',
    'model_to' => '\\Model\\Auth_Permission',
    'key_to' => 'id',
    'table_through' => 'USER_USER_PERMISSIONS',
    'key_through_from' => 'user_id',
    'key_through_to' => 'perms_id',

Howdy, Stranger!

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

In this Discussion