Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Ormauth : Example permission ?
  • Hi,

    I have difficult to use permissions with Ormauth.
    Ormauth is installed and configured, tables are generated, ...

    For example, i want to check if my user have access to "read" on "page" permission in "backend" area.

    In my table, the user is in the Group id 4. No problem, i have checked with Auth::get_groups();

    In users_permissions i have create a permission like this :
    ID:1 ; area:backend ; permission:page ; actions:NULL

    In users_group_permissions i have attached the permission 1 with group 4 :
    group_id:4 ; perms_id:1 ; actions:read

    In the code, after login, i check :

    Auth::has_access("backend.page[read]");

    But it's return false. I forget somethings ?


    PS: I flush cache before the check access
    PS: If i change the group of the user for "Super Admin". The has_access return false too.
  • actions is a serialized indexed array with zero or more actions, so it should contain

    serialize(array('read'))

    Just tested it here, and tested a user with a Super Admin role, and I get full access? Does this user have a permission assigned with a 'D' filter (which will block the 'A' filter)?
  • Thanks for you answer.

    Ok, i've regenerated tables with auth migration. And i've put "a:1:{i:0;s:4:"read";}" in the field actions.

    But don't work again, even with Super Admin role.. 


    The code in controller for check access : 

                $user_id = Auth::get_user_id();
                $user = \Auth\Model\Auth_User::find($user_id[1]);
                Debug::dump($user);
                
                if (Auth::has_access('backend.page.read')) {
                    echo "OK !";
                } else {
                    echo "No access !";
                }
                self::flush_auth();

    function flush_auth() contains :

            // flush all the cached permissions
            \Cache::delete(\Config::get('ormauth.cache_prefix', 'auth').'.permissions');

            // flush all the cached groups
            \Cache::delete(\Config::get('ormauth.cache_prefix', 'auth').'.groups');

            // flush all the cached roles
            \Cache::delete(\Config::get('ormauth.cache_prefix', 'auth').'.roles');
  • I've found issue :
    \Cache::delete(\Config::get('ormauth.cache_prefix', 'auth').'.permissions');

    Don't flush all cached permissions

    It's work if i do :
            \Cache::delete(\Config::get('ormauth.cache_prefix', 'auth').'.permissions.user_0');
            \Cache::delete(\Config::get('ormauth.cache_prefix', 'auth').'.permissions.user_2');

    But how i can easily flush all cached permissions user ?
  • \Cache::delete_all() deletes an entire tree.

Howdy, Stranger!

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

In this Discussion