Okay, so I am two weeks into learning Yii. I have an Administrator/Manager portal all working well with in a matter of those two weeks. What I am trying to do now is create a small User portal where a user can login and change a couple of their settings, which will later expand. The application is a a web-based administration tool to manage a Postfix+Dovecot email environment, much like PostfixAdmin, which I dislike and has not been updated in a long time.
So, scenario: Administrators login to the Administration portal using credentials from the "users" table in the database while normal Users will login using their email address and password from the "account" table in the database. I am simply providing an interface to allow the user to change their password and a couple more fields. Now, I have the user authentication setup and working fine with the email address and password from the "account" table. What I cannot figure out now is how to get the "actionProfile()" method that is part of the AccountController to use the ID return from Yii::app()->user->getId(). Here is what I have:
public function actionProfile()
{
$model=$this->loadModel(array('account_id'=>Yii::app()->user->getId()));
/*
if(isset($_POST['Account']))
{
$model->attributes=$_POST['Account'];
if($model->save())
$this->redirect(array('site/index'));
}
*/
$this->render('profile',array(
'model'=>$model,
));
}
I don’t want to pass any variables through the URL and ideally, I would like every method within the ActionController to be executed using the “account_id” in the “WHERE” clause, if you will. In other words, the next method “actionPassword()” to change the users password by first confirming the current password will need to be executed using the “account_id” as well.
Any help is definitely appreciated.
Thank you in advance!