= Html::encode($this->title) ?>
+ +Введите ваш e-mail
+ +diff --git a/console/migrations/m151204_095541_add_field_password_reset_token_accounts.php b/console/migrations/m151204_095541_add_field_password_reset_token_accounts.php new file mode 100644 index 0000000..aedae70 --- /dev/null +++ b/console/migrations/m151204_095541_add_field_password_reset_token_accounts.php @@ -0,0 +1,34 @@ +execute($view); + } + + public function down() + { + echo "m151204_095541_add_field_password_reset_token_accounts cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 34f351c..e4a6bf6 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -15,6 +15,7 @@ use frontend\models\ContactForm; use yii\base\InvalidParamException; use yii\web\BadRequestHttpException; use yii\web\Controller; + use yii\filters\VerbFilter; use yii\filters\AccessControl; use common\models\Callback; @@ -365,14 +366,17 @@ class SiteController extends Controller */ public function actionRequestPasswordReset() { + $this->layout = '/internal'; + $model = new PasswordResetRequestForm(); if ($model->load(Yii::$app->request->post()) && $model->validate()) { + if ($model->sendEmail()) { - Yii::$app->session->setFlash('success', 'Check your email for further instructions.'); + Yii::$app->session->setFlash('success', 'Для того, чтобы изменить пароль, перейдите по ссылке, которая придет Вам на email'); return $this->goHome(); } else { - Yii::$app->session->setFlash('error', 'Sorry, we are unable to reset password for email provided.'); + Yii::$app->session->setFlash('error', 'Пользователя с таким e-mail в базе не существует'); } } diff --git a/frontend/models/PasswordResetRequestForm.php b/frontend/models/PasswordResetRequestForm.php index 20c6810..ddf1cc4 100755 --- a/frontend/models/PasswordResetRequestForm.php +++ b/frontend/models/PasswordResetRequestForm.php @@ -1,9 +1,9 @@ '\common\models\User', - 'filter' => ['status' => User::STATUS_ACTIVE], - 'message' => 'There is no user with such email.' + 'targetClass' => '\common\models\Accounts', + 'message' => 'Пользователя с таким e-mail в базе не существует.' ], ]; } @@ -35,23 +34,24 @@ class PasswordResetRequestForm extends Model */ public function sendEmail() { - /* @var $user User */ - $user = User::findOne([ - 'status' => User::STATUS_ACTIVE, + + /* @var $user Accounts */ + $user = Accounts::findOne([ 'email' => $this->email, ]); if ($user) { - if (!User::isPasswordResetTokenValid($user->password_reset_token)) { + if (!Accounts::isPasswordResetTokenValid($user->password_reset_token)) { $user->generatePasswordResetToken(); } if ($user->save()) { - return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user]) - ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) - ->setTo($this->email) - ->setSubject('Password reset for ' . \Yii::$app->name) - ->send(); + $form = array(); + $form ['email'] = $user->email; + $form ['name'] = $user->name; + $form ['pass'] = $user->pass; + return Emails::get('remide',$form,$form ['email']); + } } diff --git a/frontend/views/accounts/cabinet.php b/frontend/views/accounts/cabinet.php index d883661..93c21c9 100755 --- a/frontend/views/accounts/cabinet.php +++ b/frontend/views/accounts/cabinet.php @@ -3,6 +3,7 @@ use \yii\widgets\ActiveForm; use \yii\helpers\ArrayHelper; use \common\models\DicCities; use \common\models\Deliveries; +use \yii\helpers\Url; $this->registerCssFile('/css/about_company.css'); $this->registerCssFile('/css/style/notepad.css'); @@ -17,16 +18,18 @@ $this->params['breadcrumbs'][] = $this->title;
Мой профиль