crisu83 / yii-rights

Automatically exported from code.google.com/p/yii-rights
BSD 3-Clause "New" or "Revised" License
2 stars 4 forks source link

problem with column named "name" #71

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.if i add a column name named "name" to user table
2.
3.

What is the expected output? What do you see instead?
i have to access to rights page but i see this message "You are not authorized 
to perform this action"

What version of the product are you using? On what operating system?
version 1.3.0. windows 7

Please provide any additional information below.
i have no idea why when i add a column "name" to table user i see this message. 
maybe this "name" is a reserved word in your module or a reserved word in 
mysql. 

Original issue reported on code.google.com by shayan3...@gmail.com on 6 Mar 2012 at 11:12

GoogleCodeExporter commented 9 years ago
I came accross the same issue. So far I think this problem is related to the 
use of the RUserBehaviour. It seems the Rights Module relies on this behaviour 
to determine the username by attempting to add the getName() method to the user 
model. When the column exists in the User model's table, the CActiveRecord's 
automagic getter method seems to take precedence over the behaviour's getName() 
method. 

I was able to fix this problem by adding the method getRightsUserName to the 
RUserBehaviour.php file on line 48:

public function getRightsUserName()
{
    return $this->getName();
}

and replace:

$superusers[] = $user->name;

with: 

$superusers[] = $user->rightsUserName;

in RAuthorizer.php on line 300

Original comment by lennart...@gmail.com on 31 Mar 2012 at 10:39

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Alternately, change $superusers[] = $user->name to whatever you have for 
login_name like $user->login_name.  It works.

Original comment by Aravinds...@gmail.com on 24 May 2012 at 11:01