[size="3"][center]How to install the Rights without error 403![/center][/size]
- First of all, you must configure authentication using a database. You must configure the creation, deletion user using the database, as well as the login to the site. The users table must be named ‘users’.
I use a table users like this:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`login` varchar(50) NOT NULL,
`pass` varchar(50) NOT NULL,
`email` varchar(32) NOT NULL,
`lang` varchar(2) NOT NULL DEFAULT '',
`rememberme` int(1) NOT NULL DEFAULT '0',
`regdate` datetime NOT NULL,
`last_update` datetime NOT NULL,
`last_comin` datetime NOT NULL,
`active` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
- Create a user with the username ‘admin’. His id should be 1 (id=1)
Install the Rights.
-
Unpack the archive in protected/modules/rights
-
Correct the config/main
in Import section:
'import'=>array(
'application.modules.rights.*',
'application.modules.rights.components.*', // Correct paths if necessary.
),
in Components section:
'components'=>array(
'user'=>array(
'class'=>'RWebUser', // Allows super users access implicitly.
//'defaultRoles'=>'Guest',
),
in authManager section:
'authManager'=>array(
'class'=>'RDbAuthManager', // Provides support authorization item sorting.
),
in modules section:
'modules'=>array(
'rights' => array (
'superuserName' => 'SuperAdmin',
'authenticatedName' => 'Authenticated',
'userClass' => 'Users',
'userIdColumn' => 'id', // Name of the user id column in the database.
'userNameColumn' => 'login', // Name of the user name column in the database.
'enableBizRule' => false, // Whether to enable authorization item business rules.
'enableBizRuleData' => false, // Whether to enable data for business rules.
'displayDescription' => true, // 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' => 'webroot.themes.office.views.layouts.main', // Application layout.
//'appLayout' => 'application.modules.admin.views.layouts.main', // Application layout.
//'cssFile' => 'rights.css', // Style sheet file to use for Rights.
'install' => false,
),
),
- Make sure that
'install' => true,
-
Entering a site under the ‘admin’ account
-
Call mysite/index.php?r=rights or mysite/index.php/rights.
Get:
Congratulations! Rights has been installed succesfully…
or not …
)
If you are use ‘login’ field in the table ‘users’ as I am, but not the field ‘name’ as conceived by the author,
You get famous Error 403 There must be at least one superuser!.
You have two ways:
1. Use a table ‘users’ like this
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(50) NOT NULL,
`pass` varchar(50) NOT NULL,
`email` varchar(32) NOT NULL,
`lang` varchar(2) NOT NULL DEFAULT '',
`rememberme` int(1) NOT NULL DEFAULT '0',
`regdate` datetime NOT NULL,
`last_update` datetime NOT NULL,
`last_comin` datetime NOT NULL,
`active` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
and run again.
2. Make such magical passes:
2.1. in components/RAuthorizer.php, around line 300, change
$superusers[] = $user->name;
to
$superusers[] = $user->{Rights::module()->userNameColumn};
2.2. in /protected/components/UserIdentity.php add lines:
$this->username = $rec->login;
$this->setState( 'userlogin', $rec->login );
$this->setState( 'name', $rec->name );
(my rquest is: $rec = Users::model()->findByAttributes( array ( ‘login’ => $this->username ) ); )
2.3. ALTER TABLE users
ADD name
VARCHAR( 64 ) NULL AFTER login
;
2.4. Assign the "admin" value to the "name" field
2.5. Entering under the username ‘admin’ and call mysite/index.php?r=rights или mysite/index.php/rights
Get:
Congratulations! …
Now we return everything back
2.6. Delete the line
$this->setState( 'userlogin', $rec->login );
in /protected/components/UserIdentity.php
2.7. ALTER TABLE users
DROP name
2.8. Set
'install' => false,
in config/main
And finally,
It is also important that the names of the tables had such this: (note the capital letters)
AuthAssignment, AuthItem, AuthItemChild and Rights
Regards, guys