Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add user #53

Open
msaebi031 opened this issue May 12, 2024 · 7 comments
Open

add user #53

msaebi031 opened this issue May 12, 2024 · 7 comments

Comments

@msaebi031
Copy link

سلام من با کد زیر یوزر اضافه میکنم
ولی نمیتونم یوزرنیم و پسوورد براش در نظر بگیرم باید چیکار کنم؟ و چه پارامتری بهش اضافه کنم؟

 async addUser(count, credit, group_name, isp_name, username, password) {
    this.params[0].count = count;
    this.params[0].credit = credit;
    this.params[0].group_name = group_name;
    this.params[0].credit_comment = isp_name;
    this.params[0].owner_name = "system";

    try {
      const value = await new Promise((resolve, reject) => {
        this.client.methodCall("user.addNewUsers", this.params, (error, value) => {
          if (error) {
            reject(error);
          } else {
            resolve(value);
          }
        });
      });
      return value;
    } catch (error) {
      throw error;
    }
  }
@ilius
Copy link
Contributor

ilius commented May 12, 2024

@msaebi031
Copy link
Author

msaebi031 commented May 12, 2024

استفاده میکنم ولی کار نمیکند

class Ibsng {
  constructor() {
    const serverOptions = {
      host: process.env.HOST_ISBNG,
      port: process.env.PORT_ISBNG,
      path: "/", // مسیر مورد نیاز
      headers: {
        "User-Agent": "xmlrpc",
        "Content-Type": "application/xml",
        Accept: "application/xml",
      },
    };

    // ایجاد یک کلاینت XML-RPC
    this.client = xmlrpc.createClient(serverOptions);

    // ارسال درخواست به سرور
    this.params = [
      {
        auth_remoteaddr: process.env.HOST_ISBNG,
        auth_name: process.env.NAME_ISBNG,
        auth_pass: process.env.PASSWORD_ISBNG,
        auth_type: "ADMIN",
      },
    ];
  }
async setUserAttributes(user_id, username, password) {
    this.params[0].user_id = "170894";
    this.params[0].attrs = {
      normal_user_spec: {
        normal_username: "tessetstet",
        normal_password: 123456789,
      },
    };
    this.params[0].to_del_attrs = [];
    try {
      const value = await new Promise((resolve, reject) => {
        this.client.methodCall("user.updateUserAttrs", this.params, (error, value) => {
          if (error) {
            reject(error);
          } else {
            resolve(value);
          }
        });
      });
      return value;
    } catch (error) {
      throw error;
    }
  }
}

@ilius
Copy link
Contributor

ilius commented May 12, 2024

چه اروری می‌گیرید؟

چرا this.params لیست است؟
جیسونی که می‌فرستید باید object باشه.

@ilius
Copy link
Contributor

ilius commented May 12, 2024

سمپل‌کدهای پایتون و php رو لطفاً بخونید.
https://github.com/ParspooyeshFanavar/ibsng-docs/tree/master/json-rpc/sample-code

@msaebi031
Copy link
Author

msaebi031 commented May 12, 2024

هیچ چیزی نمیگه بهم
روی سمپل ها پیش رفتم ولی هیچ تغییری نمی کنه
لیستی که ارسال میشه :

[
  {
    auth_remoteaddr: 'xx-xx-xxx-xx',
    auth_name: 'system',
    auth_pass: '0410062731',
    auth_type: 'ADMIN',
    user_id: '170888',
    attrs: { normal_user_spec: {
        normal_username: "tessetstet",
        normal_password: 123456789,
      } },
    to_del_attrs: []
  }
]

@msaebi031
Copy link
Author

امکانش هست یک دسترسی تلگرام به بنده بدید؟

@ilius
Copy link
Contributor

ilius commented May 12, 2024

چرا داخل لیست گذاشتید؟
از لیست بیارید بیرون.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants