user->isGuest) { return $this->goHome(); } $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('index', [ 'model' => $model, ]); } } public function actionLogout() { Yii::$app->user->logout(); return $this->goHome(); } public function actionForgot(){ $model = new Customer; if(!empty($_POST['Customer']['username'])){ if($user = Customer::find()->where(['username'=>$_POST['Customer']['username']])->one()) Mailer::widget( ['type' => 'password', 'subject'=> 'Ваш пароль', 'email' => $user->email, 'params' => $user, ]); $user->sendMsg(); Yii::$app->getSession()->setFlash('success', 'На указанный Вами эмейл отправленно письмо с паролем!'); return $this->refresh(); } return $this->render('forgot', [ 'model' => $model, ]); } }