Welcome Guest, Not a member yet? Register   Sign In
Myth Auth - Working with groups and permissions
#1

Any documentation on how to deploy groups and permissions using myth?

I inserted this data into the auth_groups table:
ID | Name | Description
1   | Admin | Admin
2   | Member | Member

auth_groups_users
group_id | user_id
1 | 1
2| 2

auth_groups_permissions
group_id | permission_id
1 | 1

auth_permissions
id | name | description
1| admin | admin

I have two users:
1 = Admin
2 = Member

Routes:
PHP Code:
$routes->group('/', ['filter' => 'login'], function($routes){
 
$routes->group('users', ['filter' => 'role:admin'],function($routes){

 });
}); 

but the administrator when accessing the route users says he doesn't have permission
Reply
#2

(This post was last modified: 06-23-2021, 12:53 AM by paliz.)

How do you ceck premission s

Use filter or check in controller!?

I would recoment use filter before any action post get put delete
Enlightenment  Is  Freedom
Reply
#3

auth_helper
PHP Code:
has_permission($permission)
// true/false 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

I found this inside the repository

https://github.com/lonnieezell/myth-auth...ization.md

What I understood so far is:
role=group
permission=group permission
Reply
#5

It has premission for user tooo

You can use rule base or prmission yatem to access


Look at filters you ll see
Enlightenment  Is  Freedom
Reply
#6

I've looked at the filters but it seems to only work with groups not users.

PHP Code:
$authorize service('authorization');
$authorize->inGroup('teste'1), // check if user 1 is in the 'teste' group
$authorize->hasPermission('users-add'1), //checks if group 1 has 'users-add' permission
$authorize->doesUserHavePermission(1,'users-add'), //check if there is any user with 'users-add' permission in group 1 



I didn't find anything specific to work with users, but in the database there is a table called "auth_users_permissions"

I will keep doing some tests
Reply
#7

Are sure i tested it work for user permissions too
Enlightenment  Is  Freedom
Reply
#8

(This post was last modified: 06-24-2021, 05:42 AM by ikesela.)

for role, you need to set role in auth_groups, then add user to auth_group_users
auth_groups
1 | admin
2 | member

auth_group_users
group_id | user_id
1 | 1
2 | 2

this 2, enough for setting role in filter

for permission, set permission in auth_permissions , then add user to auth_user_permissions (for user) or auth_groups_permissions (for group)
Reply
#9

(06-23-2021, 11:00 PM)paliz Wrote: Are sure i tested it work for user permissions too

which version did you use?, i am using release 1


ikesela Wrote:...then add user to auth_user_permissions (for user)...

So am I required to declare a group and give permissions to it and then to the user?

I wanted it to be user-only without having to put him in a group.
Reply
#10

(This post was last modified: 06-25-2021, 04:41 AM by manager.)

(06-24-2021, 06:40 AM)rafinhaa Wrote: So am I required to declare a group and give permissions to it and then to the user?

I wanted it to be user-only without having to put him in a group.
Myth Auth  operates with many concepts such groups (roles) and permissions. User may belong to some single group or groups. Groups = Roles.

After registration process if $defaultUserGroup variable in config file  is empty (no default group), then user will not belong to any group.

To work with permissions you need create them first and set some to the user. Then you can call methods to check user has permission and do some logic.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB