Hi all, I am new to Yii, and now developing a new web apps with Yii.
My question is, after validate user login,
$form->attributes=$_POST['UserLoginForm']; if($form->validate()) { # Store this logined user information Yii::app()->user->setId(81); # Id should get from DB Yii::app()->user->setName("blablabla"); # Name should get from DB $this->redirect(Yii::app()->getBaseUrl()."/index.php?r=admin"); }
Both 2 lines should I put? I mean should I put under
-
UserIdentity.php component, directly add this 2 lines after SQL validation (inside authenticate function)
-
Under this controller/action, if this case, need to query the DB again for the Id/Name.
I understand we should keep a component as modular as possible, if I use the first option, then UserIdentity component is doing additional job other then only perform authentication, which is not modular enough.
If I use the second approach, then need to perform additional db jobs, wasting resources.
Can anybody advice? Or is there any other methods?
Thanks in advance.