KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I started to make some differences between those users which have authenticated and those that not. For this, i am using Yii::app()->user->id; However, in a determined view i put the following code: <?php if(Yii::app()->user->isGuest) { print("Welcome back Guest!"); print("Your id is ".Yii::app()->user->id); } else { print("Welcome back ".Yii::app()->user->name); print("Your id is ".Yii::app()->user->id); }?> And i always get the "welcome back guest!", whether i have logged in (successfully) or not. And if i have logged in, then it displays the welcome message together with the user's id! EDIT @briiC.lv Hey.. sorry for the late reply, I hope you are still following this! I am not extending the given UserIdentity class. Is this mandatory? Since i still dont get very well the whole authorization issue, i thought it would be best to give a try with the class they provide, and then extend with my own functionality.. Anyway, next i post my UserIdentity class with its small tweaks.. maybe the problem lies here?? <?php class UserIdentity extends CUserIdentity{ private $_id; public function authenticate() { $user = Users::model()->findAll('username=\''.$this->username.'\' AND password=\''.$this->encryptedPassword.'\''); if(!isset($user[0])) { return false; } else { $this->setState('id', $user[0]->id); $this->username = $user[0]->username; $this->errorCode=self::ERROR_NONE; return true; } } public function getId() { return $this->_id; } } Here is the output i got when i started to log as you suggested; i got this output immediately after successfully logging in. [05:23:21.833][trace][vardump] CWebUser#1 ( [allo
Tags (comma-separated)
Save Edits
Cancel