We used Yii2 framework last alpha. Role for user already created but problem is how it assign to user. Documentation is absent.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Solved!
================ create role ============
=============== assign ==================
For database version of RBAC use DbManager (quote frm: Alexufo):
Example Access rules:
Don't forget to add this to your configuration file (config/main.php):
Tables:
You can also find this information in the "yii/rbac" directory (including other SQL files). For functionality and more details:
https://github.com/yiisoft/yii2/blob/master/docs/guide/security-authorization.md
A really simple way to achieve an admin role is to add this to your controller:
Then add to your
User
model anisAdmin()
which returnstrue
for your admin user(s) andfalse
for everyone else. Personally, I use:Admittedly, this is not "by the book". But it is simple, quick and effective.
========================================================================= if you want to select role instead creating then
100% worked!