Hello!
I have 2 tables: tbl_users and tbl_pj in mysql database.
I’m trying to modify action Login to redirect (after successful login) not to returnUrl but to
a) in case user is admin - to redirect to crud page of users, so admin can add/delete/update users
in case user is simple user - to redirect to other crud pj where authenticated users can add/delete/update
records in table pj.
Any suggestions?
arbir
(Arvind Rangan)
2
Hi,
This is easy…
assuming you are going with the default code generated by the yiic tool.
inside your /yourapp/protected/controllers/SiteController.php
find the actionLogin()
there you will find this line
if($form->validate())
$this->redirect(Yii::app()->user->returnUrl);
change ur logic here like
if($form->validate())
{
if (Yii::app()->user->id==‘admin’) /* which ever way u implement adminc check*/
$this->redirect(‘myview/admin’);
else
$this->redirect(Yii::app()->user->returnUrl);
}
enjoy!
Arvind