I use postgresql (because i need it for my aplication) and i looked in the schema.sql but it’s seems to be Mysql only. Is it me or is this not gonna work on postgre (altho the documentation says it’s cross-database) ?
Before i used rights (only had a ‘User’ model), i extended the login function because it needs to check username and pasword in a different database (yeh complicated appilication). This worked fine without rights installed. Can you tell me which function i need to edit, or to extend to change this?
@Mukke: Rights uses Yii’s built-in database authorization manager (CDbAuthManager) and I understand that it work with PostgreSQL. Please try it and report back. What comes to your second question you only need to configure the user model name if it’s not ‘User’, an id column if it isn’t ‘id’ and a name column if it isn’t ‘username’. For further information please refer to the documentation.
if you want to see parents, childs and add childs list with their names and not with description (if description is not empty), you’ve 2 solutions:
change on protected/modules/rights/views/authItem/update.php $data->getNameLink() with $data->getNameLink(false) and on controller getNameText() to getNameText(false)
change on protected/modules/rights/components/RightsAuthItemBehavior.php getNameText and getNameLink argument $humanReadable to false
Hi, I’m fairly new to Yii, so bear with me. I installed Yii-user and Yii-rights and everything looks good. I’m creating a subscription based site. If a user does not belong to role-subscriber, I’d like to redirect them to a subscription signup page.
My thoughts on doing this are to create a new class that extends RightsWebUser (../modules/rights/components/RightsWebUser.php) and overrides the afterLogin() method. I’d call parent::afterLogin() to execute the old functionality and guard against updates to Rights, then execute any new functionality. In the ../config/main.php file, I’d replace
‘class’=>‘RightsWebUser’ with ‘class’=>‘MyRightsWebUser’.
Does this sound like the correct approach? If so, where is the best place to put the MyRightsWebUser.php file?
I put some proof of concept code in MyRightsWebUser.php and put it in the app level directory, ../protected/components. It worked like a charm, at least for a simple redirect. I have to lookup the syntax for checking if a user is a member of a role, but it looks promising.
What if I want to change the name of the table,say ‘AuthAssignment’, to ‘tbl_authassignment’, for table name consistency? I scanned this thread and found no concern regarding this…or maybe I just missed it,please correct me.
I’m enjoying exploring the codes, but I’m really lost now. Please help
I assigned the user ‘demo’ to the role ‘Authenticated’ and given him the permissions ‘Menu.Create’ and ‘Menu.Index’, which were generated from the controllers using this amazing extension. Then I extended my class ‘Controller’ to ‘RightsBaseController’, then edited the function
public function filters()
{
return array(
'rights', // perform access control for CRUD operations
);
}
in class ‘MenuController’ (which extends to ‘Controller’). My problem is, I cannot access a Menu action (even index and create) unless I add them to allowedActions():
public function allowedActions()
{
return 'index';
}
which actually defeats the purpose of this extension. I’m sure I did something wrong, I just don’t know where to look at
When I changed the filters from ‘accessControl’ to ‘rights’, my MenuController do not use the accessRules anymore,right?
I created a new web application and tested Rights, along with Yii-User and both works fine. But Rights still won’t work with my current web app for some reason, so I guess I’ll just rewrite my application on top of my newly created web app.
I’ve update the blog demo to reflect on the recent changes and I also took some time to review some logic for updating own posts.
@mjkulet: Thanks for pointing out the typos in the permissions view! It’s now fixed. About your problem with checking access, did you assign those operations to the user or the role?
Most likely you don’t want to use two different filters to check access so I wouldn’t recommend using ‘rights’ and ‘accessControl’ in the same controller. Keep in mind that it’s not necessary to use Rights for all of your controllers. Sometimes it may be more convenient to use the built-in access control instead (e.g. backend).