Yii Framework Forum: yii-user with rights - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

yii-user with rights Rate Topic: ***** 2 Votes

#21 User is offline   Chris83 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 440
  • Joined: 27-February 10
  • Location:Helsinki, Finland

Posted 19 January 2011 - 03:22 PM

View PostRodrigo79, on 19 January 2011 - 11:36 AM, said:

First of all, great extensions both yii-user and rights.
I've a question for those who manage to make them work together. I'm a begginer at Yii so maybe this is to basic, but while the two extensions work with users, which model is loaded? I need to extend the user model or access the profile fields but when I call user->something it tells me RWebUser doesn't have that field or method.
Thanks, and congratulations all for the good work.


Hello Rodrigo79,

Well, as far as I know, both modules come with an own web user class so you need to change either RWebUser to extend the yii-user's web user or vice versa. If you need an own web user class you need to extend your application web user from the one extending the other. Please let me know if you don't understand what I mean.
Best regards,
Chris

My contribution to the Yii community:
Account | Yiistrap | Auth | Bootstrap | NordCms | Rights | LESS | SEO | Img

Follow me:
Twitter | GitHub | Bitbucket
0

#22 User is offline   kingsol 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 09-January 11

Posted 19 January 2011 - 09:50 PM

View PostChris83, on 19 January 2011 - 03:19 PM, said:

Hey kingsol,

I'm not entirely sure but I think that's a bug that I have fixed in the latest release. Please update Rights and try again. If you're already running the newest version please report back and we'll try to figure out what the problem is.


Chris83, I thought I had the current version but apparently not because that appears to have fixed the issue.

Thank you for the prompt reply! Very nice work on the module.
0

#23 User is offline   Rodrigo79 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 19-January 11

Posted 20 January 2011 - 10:36 AM

View PostChris83, on 19 January 2011 - 03:22 PM, said:

Hello Rodrigo79,

Well, as far as I know, both modules come with an own web user class so you need to change either RWebUser to extend the yii-user's web user or vice versa. If you need an own web user class you need to extend your application web user from the one extending the other. Please let me know if you don't understand what I mean.


Thanks Chris. I got it working by extending RWebUser and loading the user model from yii-user. Since yii-user doesn't use its own web user class, seemed easier that way ;)
0

#24 User is offline   danieln 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 17-January 11

Posted 21 January 2011 - 03:15 PM

View PostChris83, on 19 January 2011 - 03:22 PM, said:

Hello Rodrigo79,

Well, as far as I know, both modules come with an own web user class so you need to change either RWebUser to extend the yii-user's web user or vice versa. If you need an own web user class you need to extend your application web user from the one extending the other. Please let me know if you don't understand what I mean.


Hi,

Sorry, but I don't get what is meant here, or how it's supposed to be done.

I followed the sample for the controller main.php file, but I always get an error at the last lines below

'components'=>array(
'user'=>array(
// enable cookie-based authentication
//'class'=>'RightsWebUser',
'allowAutoLogin'=>true,
'loginUrl' => array('/user/login'),
),
class Controller extends RightsBaseController 'authManager'=>array('class'=>'RightsAuthManager'), (error alert here in dreamweaver)

even the change on component/controller.php with 'class Controller extends RightsBaseController
' also gave me an error. :(

any samples around how you guys got it working?
0

#25 User is offline   kingsol 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 09-January 11

Posted 21 January 2011 - 04:24 PM

View Postkingsol, on 19 January 2011 - 09:50 PM, said:

Chris83, I thought I had the current version but apparently not because that appears to have fixed the issue.

Thank you for the prompt reply! Very nice work on the module.


So, turns out it wasn't resolved by updating to the current version, but I did figure out the problem. I thought I would share for the benefit of the forum.

I had logged in, enabled right, created roles, and assigned people to the roles (including admin). At that time, I hadn't assigned operations to the roles yet.

Then left and came back the next day (and consequently logged out).

That is where the infinite redirect loop happened. To resolve, I commented out the filters in the primary controller, went into rights and added operations to the roles, logged out, uncommented the filters in the primary controller, and logged back in.

:) Again, thanks for a great module!
0

#26 User is offline   kingsol 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 09-January 11

Posted 21 January 2011 - 04:30 PM

So another question for you Chris83... I have situation where I have an Accounts Model. An account will have multiple users. A user can be on multiple accounts as well. Here is the kicker, I would love to some how give a user a ROLE, based on their relationship with an Account.

i.e.

Account ACME
John Doe - Role: A
Jane Doe - Role: B
Jack Doe - Role: C

Account XYZ
Jack Doe - Role: B
Jane Doe - Role: D

Would that be possible? How would you approach it?

Many Thanks!
0

#27 User is offline   arbuscula 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 20-February 11

Posted 20 February 2011 - 02:46 PM

1.Set yii-user: the configuration and added to the database table (tbl_profiles, tbl_profiles_fileds, tbl_users).

2.Set the extension-rights: the configuration and added to the database table (authassignment, authitem, authitemchild, rights, user)
3. Expanded RController (Controller)
4. Configured authManager

And nothing works. When you add rules, options, problems wrote:
Property "CWebUser.rightsReturnUrl" is not defined.
And if 'install' => true, writes: Application web user must extend the RWebUser class.
0

#28 User is offline   Deep Thought II 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 26-January 11

Posted 18 April 2011 - 11:23 AM

this is post is awesome, it has helped me setup rights & users together. though some contents are outdated, but using some best judgement and latest documentation from both, it worked like a charm!
0

#29 User is offline   Deep Thought II 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 26-January 11

Posted 18 April 2011 - 11:29 AM

sharing my setup:

1. setup user as in its documentation
2. setup rights as in its documentation
3. the particular sections of my main becomes:

'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.user.models.*',
'application.modules.user.components.*',
'application.modules.rights.*',
'application.modules.rights.components.*', // Correct paths if necessary.

),

'modules'=>array(
// uncomment the following to enable the Gii tool

'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'xxx',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),

'user',
'rights'=>array( 'install'=>false, // Enables the installer.
),

),

'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl' => array('/user/login'),
'class'=>'RWebUser',
),
'authManager'=>array( 'class'=>'RDbAuthManager',
'defaultRoles'=>array('Guest'),
),

'rights'=>array( 'superuserName'=>'Admin', // Name of the role with super user privileges.
'authenticatedName'=>'Authenticated', // Name of the authenticated user role.
'userIdColumn'=>'id', // Name of the user id column in the database.
'userNameColumn'=>'username', // Name of the user name column in the database.
'enableBizRule'=>true, // Whether to enable authorization item business rules.
'enableBizRuleData'=>false, // Whether to enable data for business rules.
'displayDescription'=>false, // Whether to use item description instead of name.
'flashSuccessKey'=>'RightsSuccess', // Key to use for setting success flash messages.
'flashErrorKey'=>'RightsError', // Key to use for setting error flash messages.
'baseUrl'=>'/rights', // Base URL for Rights. Change if module is nested.
'layout'=>'rights.views.layouts.main', // Layout to use for displaying Rights.
'appLayout'=>'application.views.layouts.main', // Application layout.
'cssFile'=>'rights.css', // Style sheet file to use for Rights.
'install'=>false, // Whether to enable installer.
'debug'=>false, // Whether to enable debug mode.
),
),

4. follow rights documentation to make controller extend from RController as well as changing/removing your controller's accessControl lines - this is also in rights documentation

5. Voila.... test and things work!
0

#30 User is offline   xav 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 50
  • Joined: 09-August 10

Posted 13 May 2011 - 05:23 AM

View PostDeep Thought II, on 18 April 2011 - 11:29 AM, said:

sharing my setup:

1. setup user as in its documentation
2. setup rights as in its documentation
3. the particular sections of my main becomes:

'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.user.models.*',
'application.modules.user.components.*',
'application.modules.rights.*',
'application.modules.rights.components.*', // Correct paths if necessary.

),

'modules'=>array(
// uncomment the following to enable the Gii tool

'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'xxx',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),

'user',
'rights'=>array( 'install'=>false, // Enables the installer.
),

),

'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'loginUrl' => array('/user/login'),
'class'=>'RWebUser',
),
'authManager'=>array( 'class'=>'RDbAuthManager',
'defaultRoles'=>array('Guest'),
),

'rights'=>array( 'superuserName'=>'Admin', // Name of the role with super user privileges.
'authenticatedName'=>'Authenticated', // Name of the authenticated user role.
'userIdColumn'=>'id', // Name of the user id column in the database.
'userNameColumn'=>'username', // Name of the user name column in the database.
'enableBizRule'=>true, // Whether to enable authorization item business rules.
'enableBizRuleData'=>false, // Whether to enable data for business rules.
'displayDescription'=>false, // Whether to use item description instead of name.
'flashSuccessKey'=>'RightsSuccess', // Key to use for setting success flash messages.
'flashErrorKey'=>'RightsError', // Key to use for setting error flash messages.
'baseUrl'=>'/rights', // Base URL for Rights. Change if module is nested.
'layout'=>'rights.views.layouts.main', // Layout to use for displaying Rights.
'appLayout'=>'application.views.layouts.main', // Application layout.
'cssFile'=>'rights.css', // Style sheet file to use for Rights.
'install'=>false, // Whether to enable installer.
'debug'=>false, // Whether to enable debug mode.
),
),

4. follow rights documentation to make controller extend from RController as well as changing/removing your controller's accessControl lines - this is also in rights documentation

5. Voila.... test and things work!



hello, I did all that and it works fine....apparently !! I came across a series of thoughts when using these two modules. At first i thought I could avoid modifying the code of an extension to be able to update with no problem. But that is not possible. The yii user code must be modified if you want, for example, assign a default role to a freshly registered user or have multiple profiles by roles.

Secondly, I've created Authorization items for the user module so no user other then admin is able to see the default list given by index.php/user/ (index action). Without success ! However, this task is assigned to no role ! So only the admin should see the list, right ?

Furthermore, i've noticed that by seeing the list the user could also click on an item and go to the view detail !!!

What I did is edit the userController.php and modify the filter to comply with rights
return array(
			'rights',
		);

and remove the rule part.

Then there was an improvement, the list was still visible but not the view detail anymore.

So I have two questions :

1. Is changing the controllers of the user extension the right move or is there another way ?
2. Why the user.default.index is still accessible after having
a.Created the tasks related to these action in rights and assigned it to none
b.Modified the userController to the 'rights' sauce ?

Regards,

xavier
0

#31 User is offline   abhimir 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 17-April 11
  • Location:India

Posted 24 May 2011 - 10:55 PM

View PostDeep Thought II, on 18 April 2011 - 11:29 AM, said:

sharing my setup:
............
........
5. Voila.... test and things work!


I followed the steps and it works like a charm now. I could so kiss your feet right now, you saved me a few hours of debugging. :D
0

#32 User is offline   tanimgt 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 07-April 11
  • Location:Bangladesh

Posted 01 June 2011 - 03:19 AM

guys, i have a funny problem, think anyone of you can fix it :-) . i changed my default controller to my home controller and also 'errorAction'=>'home/error', in my main config file after i install the 'rights' module. the module works fine but when i call any non permissioned action, it shows site/login in the url of the browser. but there is no controller named, 'site' in my application. please please can you guys help me a little ? <thanks, tanim>
0

#33 User is offline   Wiseon3 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 14-February 11

Posted 16 June 2011 - 05:12 AM

View Posttanimgt, on 01 June 2011 - 03:19 AM, said:

guys, i have a funny problem, think anyone of you can fix it :-) . i changed my default controller to my home controller and also 'errorAction'=>'home/error', in my main config file after i install the 'rights' module. the module works fine but when i call any non permissioned action, it shows site/login in the url of the browser. but there is no controller named, 'site' in my application. please please can you guys help me a little ? <thanks, tanim>

In your main config modify the user component, to change the loginURL. It should look like this:
        // application components
        'components'=>array(
#...
                'user'=>array(
                        // enable cookie-based authentication
                        'allowAutoLogin'=>true,
                        'loginUrl' => array('/user/login'),
                ),
#...
        ),

0

#34 User is offline   arash 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 38
  • Joined: 11-April 11

Posted 16 June 2011 - 05:40 AM

Hello

View Posttanimgt, on 01 June 2011 - 03:19 AM, said:

guys, i have a funny problem, think anyone of you can fix it :-) . i changed my default controller to my home controller and also 'errorAction'=>'home/error', in my main config file after i install the 'rights' module. the module works fine but when i call any non permissioned action, it shows site/login in the url of the browser. but there is no controller named, 'site' in my application. please please can you guys help me a little ? <thanks, tanim>

calling a non permissioned action will redirect you to login page, which is determined by user component, it has nothing to do with errorHandler, so just try to specify correct login page in main config file like this:
		'user'=>array(
                         .....
			'loginUrl' => array('home/login'),  // change this to proper location
		),

0

#35 User is offline   tanimgt 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 07-April 11
  • Location:Bangladesh

Posted 06 November 2011 - 12:07 AM

View Postarash, on 16 June 2011 - 05:40 AM, said:

Hello

calling a non permissioned action will redirect you to login page, which is determined by user component, it has nothing to do with errorHandler, so just try to specify correct login page in main config file like this:
		'user'=>array(
                         .....
			'loginUrl' => array('home/login'),  // change this to proper location
		),



many many thanks to both of you bro ;D ;D
0

#36 User is offline   tanimgt 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 52
  • Joined: 07-April 11
  • Location:Bangladesh

Posted 06 November 2011 - 12:09 AM

View PostWiseon3, on 16 June 2011 - 05:12 AM, said:

In your main config modify the user component, to change the loginURL. It should look like this:
        // application components
        'components'=>array(
#...
                'user'=>array(
                        // enable cookie-based authentication
                        'allowAutoLogin'=>true,
                        'loginUrl' => array('/user/login'),
                ),
#...
        ),



many many thanks to both of you bro ;D ;D
0

#37 User is offline   almix 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 23-September 11

Posted 14 November 2011 - 04:03 PM

I have such an error when try assign any user to any assignment:

CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`events`.`authassignment`, CONSTRAINT `authassignment_ibfk_1` FOREIGN KEY (`itemname`) REFERENCES `AuthItem` (`name`) ON DELETE CASCADE ON UPDATE CASCADE). The SQL statement executed was: INSERT INTO `AuthAssignment` (`itemname`, `userid`, `bizrule`, `data`) VALUES (:itemname, :userid, :bizrule, :data)

what could be wrong?


Edit - Solved this problem by deleting all "rights" module's tables, and then install rights module again (don't touch yii-user module, it works ok). Error happened when foreign key has been deleted (it happens when i change table name by hands for example)

Attached File(s)


This post has been edited by almix: 15 November 2011 - 08:04 AM

0

#38 User is offline   era123 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 25-December 11

Posted 20 February 2012 - 03:39 AM

i've followed the instructions in the doc to install the Rights module in my yii app.
But couldn't fix it yet.
always getting this error


Error

An error occurred while installing Rights.

Please try again or consult the documentation
.

i've created the tables authitem,authassigment & authitemchild tables in the database.Can any one help me.
0

#39 User is offline   artificial 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 96
  • Joined: 11-December 10
  • Location:Sydney, Australia

Posted 20 February 2012 - 03:53 AM

View Postera123, on 20 February 2012 - 03:39 AM, said:

i've followed the instructions in the doc to install the Rights module in my yii app.
But couldn't fix it yet.
always getting this error


Error

An error occurred while installing Rights.

Please try again or consult the documentation
.

i've created the tables authitem,authassigment & authitemchild tables in the database.Can any one help me.


Try deleting the database tables, make your changes to the files (i.e. download, extract rights, make necessary changes to the config) and then navigate to http://yourdomain/rights. I've only installed this particular extension once a couple of months ago, but from memory you shouldn't have to manually create the tables (I believe it does that for you).
Alex Berriman
www.fishvision.com
0

#40 User is offline   era123 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 25-December 11

Posted 20 February 2012 - 02:55 PM

View PostArtificial, on 20 February 2012 - 03:53 AM, said:

Try deleting the database tables, make your changes to the files (i.e. download, extract rights, make necessary changes to the config) and then navigate to http://yourdomain/rights. I've only installed this particular extension once a couple of months ago, but from memory you shouldn't have to manually create the tables (I believe it does that for you).


Thank you so much,
Yet i couldnt' fix it although i tried without the tables as you said.
Now it says another error

I've attached the error i got ,
And also main.php file

Attached File(s)


0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users