Also initially the tbl_user table is empty, now when I try to create a new user it shows the following error message:
"Fatal error: Call to a member function isadmin() on a non-object in C:\xampp\htdocs\saasdemo\protected\components\WebUser.php on line 87"
I am providing you with the controller code a
UserController.php:
public function actionCreate()
{
$model = (Yii::app()->user->isUserTenantAdmin()) ? new VUser : new TUser;
if(Yii::app()->user->isUserTenantAdmin() && isset($_POST['VUser'])) {
$postVars = $_POST['VUser'];
}
elseif (Yii::app()->user->isUserAppStaff() && isset($_POST['TUser'])) {
$postVars = $_POST['TUser'];
}
if(isset($postVars)) {
$model->attributes = $postVars;
if(Yii::app()->user->isUserTenantAdmin()) {
// force new user to belong to same tenant as its admin; the db trigger will insert the MySQL username
$model->tenant_id = VUser::model()->findByPk(Yii::app()->user->id)->tenant_id;
$model->tenant_owner = 0; // tenant owner is defined by app staff only
}
if ($model->validate()) {
if(Yii::app()->user->isUserAppStaff()) {
// force new user to belong to assigned tenant; the listData() in _form.php will insert the tenant_id
$model->tenant_dbu = TTenant::model()->findByPk($model->tenant_id)->dbu;
}
if($model->save(false)) { // already validated
$this->redirect(array('view','id'=>$model->id));
}
}
}
$this->render('create',array(
'model'=>$model,
));
}
The functionality will be as follows:
create user (This might act as user registration)
Username and password of the created user should be used for login