private function sendPasswordResetEmail($email) { $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $email]); if (!$user) { return false; } $user->password_reset_token = Yii::$app->security->generateRandomString(); if ($user->save(false)) { return Yii::$app->mailer->compose('@gromver/platform/frontend/modules/auth/views/emails/passwordResetToken', ['user' => $user])->setFrom(Yii::$app->grom->params['supportEmail'], Yii::t('gromver.platform', '{name} robot', ['name' => Yii::$app->grom->siteName]))->setTo($user->email)->setSubject(Yii::t('gromver.platform', 'Password reset for {name}.', ['name' => Yii::$app->grom->siteName]))->send(); } return false; }
/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return User the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = User::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(Yii::t('gromver.platform', 'The requested page does not exist.')); } }