private function sendPasswordResetEmail($email) { $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $email]); if (!$user) { return false; } $user->password_reset_token = Yii::$app->security->generateRandomKey(); if ($user->save(false)) { return \Yii::$app->mail->compose($this->module->passwordResetTokenEmail, ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($email)->setSubject(Yii::t('maddoger/user', 'Password reset for {name}', ['name' => \Yii::$app->name]))->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('maddoger/user', 'The requested user does not exist.')); } }