[Module] Yii User Management Module

edit: I’m using this module in version 0.7 from the downloadpage

hello i have an error here…my database is using a tableprefix ‘abc_’, but when i installed the module i named all tables x_*

but now i get following error after login:


The table "abc_users" for active record class "YumUser" cannot be found in the database.

but all x_ prefixed tables were successfully created…

Or when looking at the code… you probably should note somewhere, that I have to change the configs, if i use non-default tables

next thing is very wrong confusing intendention in models/YumUser.php:


 52     public function tableName()

 53     {

 54         if (isset(Yii::app()->controller->module->usersTable))

 55             $this->_tableName = Yii::app()->controller->module->usersTable;

 56         elseif (isset(Yii::app()->modules['user']['usersTable']))

 57             $this->_tableName = Yii::app()->modules['user']['usersTable'];

 58         else

 59             $this->_tableName = '{{users}}'; // fallback if nothing is set

 60             $this->_tableName = 'users'; // fallback if nothing is set

 61 

 62         return YumHelper::resolveTableName($this->_tableName,$this->getDbConnection());

 63     }



on line 60 - this must be one tab left

Has the author intention to continue working out of this project?

hello,

they just updated it about 2 weeks ago, so I guess yes …

http://www.yiiframework.com/extension/yii-user-management/

(check out the download section!)

–iM

yes, definitely. A quite big real-life project (of course YUM is involved :) ) eats up my free time at the moment. But as soon as this project comes to an end, i will merge the new developed features in the yum-svn and release a new Version. There are still some things that can be made better in Yum. Now that it slowly has gained some popularity it really gets time far a 1.0 stable release.

Thanks to google code everyone still can contribute with small fixes or features… just drop me a message and i add you to the commiters list.

Yii 1.1.3, Yum 0.7

A couple of things:

I couldn’t install as it kept saying I wasn’t in debug mode. I had to change YumInstallController.php line 37 to


if($this->module->debug === 'true')

to get it to work.

Secondly I’m getting the following error


PHP Error

Description


Trying to get property of non-object

Source File


/var/www/cf/protected/modules/user/components/YumWebUser.php(48)


00036:     }

00037: 

00038:     /**

00039:      * Checks if this (non-admin) User can administrate some users

00040:      */

00041:     public static function hasUsers($uid = 0)

00042:     {

00043:         if($uid == 0)

00044:             $uid = Yii::app()->user->getId();

00045: 

00046:         $user = YumUser::model()->findByPk($uid);

00047: 

00048: return $user->users !== array();

00049:     }

00050: 

00051: /**

00052:      * Checks if this (non-admin) User can administrate the given user

00053:      */

00054:     public static function hasUser($username, $uid = 0)

00055:     {

00056: 

00057:         if($uid == 0)

00058:             $uid = Yii::app()->user->getId();

00059: 

00060:         // Every user can modify himself


Stack Trace


#0 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/base/CComponent.php(616) : eval()'d code(1): hasUsers()

#1 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/base/CComponent.php(616): eval()

#2 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/auth/CAccessControlFilter.php(337): CAccessRule->evaluateExpression()

#3 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/auth/CAccessControlFilter.php(240): CAccessRule->isExpressionMatched()

#4 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/auth/CAccessControlFilter.php(111): CAccessRule->isUserAllowed()

#5 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/filters/CFilter.php(39): CAccessControlFilter->preFilter()

#6 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/CController.php(1049): CAccessControlFilter->filter()

#7 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/filters/CInlineFilter.php(59): YumUserController->filterAccessControl()

#8 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/filters/CFilterChain.php(126): CInlineFilter->filter()

#9 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/CController.php(283): CFilterChain->run()

#10 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/CController.php(257): YumUserController->runActionWithFilters()

#11 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/CWebApplication.php(324): YumUserController->run()

#12 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/web/CWebApplication.php(121): CWebApplication->runController()

#13 /home/nitrous/orac/software/WebDev/yii-1.1.3.r2247/framework/base/CApplication.php(135): CWebApplication->processRequest()

#14 /var/www/cf/index.php(12): CWebApplication->run()


2010-07-20 07:50:45 Apache/2.2.14 (Ubuntu) Yii Framework/1.1.3

I too got the same error… can anyone explain how to solve this…

thanks

Hi all, impressive work thyseus. Do you have intention to continue on this module?

BEst regards.

The project is certainly progressing very well indeed

line 23 of user/views/messages/index.php needs to be changed to:


YumHelper::route(\'{user}/profile\'),

As it stands there doesn’t appear to be anything to prevent reading other people’s messages by changing the message ID in the URL ie… r=user/messages/view&id=3 etc

Hi xgarb,

What version do you have?

Have you tried the latest svn? http://yii-user-management.googlecode.com/svn/trunk/

If so post back comments

Hi,

Quick test and look at the svn code shows this as fixed.

Does the messaging system have anything to prevent sending messages as someone else?

I notice the compose form has this code:




echo CHtml::activeHiddenField($model,'from_user_id', array(

				'value' => Yii::app()->user->id));



The hidden form field could be altered in the returned POST.

I have something like this:




$message->attributes=$_POST['Pm'];

$message->from_user_id=Yii::app()->user->getId();



in the controller and don’t use hidden fields.

@xgarb: good idea. I will include this in the 0.8 release !

I wanted to use ‘user management module’ with the yii blog demo. But the blog tbl_user has different structure from tbl_users. How do you integrate the two.

Also in the blog application the login is at .../site/login, while user management url points to ../user/site/login.

So basically my question is what changes to make in either blog demo or user management module so that there is no clash on url or databases.

simply follow the installation tutorial in docs/installtutorial.txt. This should work on the blog demo (and every other web application).

tbl_user doesn’t interfere with tbl_users of yii-user-management.

the link in the main menu can easily be replaced with //user/user/login so that everything works.

But I want the ‘salt’, security!

After you change url in …\blog\protected\views\layouts\main.php, to

            array('label'=>'Login', 'url'=>array('user/user/login'), 'visible'=>Yii::app()->user->isGuest),


            array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('user/user/logout'), 'visible'=>!Yii::app()->user->isGuest)

the url in the menu has an extra \user in the url once we navigate back from user management pages, i.e the ‘home’ url changes to “…user/post/index” instead of “…/post/index” and gives a 404 error. Similarly for ‘contact’ and ‘about’ links.

since yii 1.1.2 you can use the array(’//controller/action’) syntax for directly accessing the root url. (using two slashes at the beginning of the url declaration)

/ would be the module root.

so you can set the urls to //post/index so everything works fine.

you can also use a ‘//module/controller/action’ syntax.

but you are right, this definitely should go into the documentation.

Thanks, it works like a dream…

Pls. put in ‘salt’. You have already defined it in UserModule.php