public function actionResetPassword() { $model = new ResetPasswordForm(); if (!$model->checkCode()) { $this->redirect(Yii::app()->homeUrl); } // collect user input data if (isset($_POST['ResetPasswordForm'])) { $model->attributes = $_POST['ResetPasswordForm']; // validate user input and redirect to the previous page if valid if ($model->validate()) { if ($model->changePassword()) { $model->clear(); Yii::app()->user->logout(false); Yii::app()->user->setFlash('success', Yii::t('common', 'Password is changed successfully. Log in with your new password.')); $this->redirect(array('/site/login')); } else { Yii::app()->user->setFlash('error', Yii::t('common', 'Something goes wrong')); } } } $this->pageTitle = array('Reset Password'); $this->render('resetPassword', array('model' => $model)); }