Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
i was work with Warden package and need to switch on ormauth but i don't understand how ormauth work.
in warden : (number is record id)
roles : articles(1), users(2), menu(3)
permissions : for article ('create'(1), 'edit'(2), 'delete'(3),....)
assign by roles_permissions (role, permission) => (1,1),(1,2),(1,3)
user can have article role for access. (user1 have role 1 and can create, edit, delete)
and check access by Warden::can(array('create'), 'articles') for current user access to article->create
problem is if i want to define user by only edit permission, must define new role.
How can I do the same thing with ormauth package; (i don't understand document)
I recently explained how it works: see
i read that, but i need sample code
I don't really have sample code, as most of Ormauth is just ORM, so you create records and relations like you would do with any other ORM object.
Only thing special is the "action" column in the permission. It contains a serialized indexed array with possible actions and a subset of the index can be part of the relation record.
Ormauth has two permission levels, indicated by the area and the permission column. Since you only need two levels deep, the easiest is to create Permission objects "article.create", "article.edit", "article.delete" and so on. And forget the complexity of actions.
You can then create for example a role record called "Article Editor" to which you relate the "create" and "edit" permissions, and a role record like "Article Moderator" to which you relate only "edit" and "delete".
Once done you can relate a user to that role, and use Auth::has_access("article.edit") to test the permission.
Note that the users effective permissions are cached, so if you change permissions, don't forget to flush the cache.
Add a Comment
It looks like you're new here. If you want to get involved, click one of these buttons!
Apply for Membership
↳ Job Board
↳ Installation & Setup
↳ Tips and Tutorials
↳ Code share
In this Discussion