CyberHosting

How can I set default "Website limit = 0" for every new user register.

Hi there,

I'm using this api https://cyberpanel.docs.apiary.io but can't see that, would you help me about that?
In addition, the api login is failing: string(67) "{"error_message": "\"u'username'\"", "userID": 0, "loginStatus": 0}"

Thanks!
p/s: sorry for my English

Comments

  • @wordpressuser

    What kind of payload are you sending to the api end point?
  • edited October 25
    User and pass of user (not admin)

    p/s: How can I set default "Website limit = 0" for every new user register?

    My code for check login :

    class WP_Cyber_Panel{

    //Server credentials
    protected $cyberpanel_hostname = '';
    protected $admin_user = '';
    protected $admin_pass = '';

    public function __construct($hostname, $username, $password){

    $this->cyberpanel_hostname = $hostname;
    $this->admin_user = $username;
    $this->admin_pass = $password;

    }

    // curl function
    private function curl_result($action, $postdata){

    $postdata = json_encode($postdata);

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, "https://" . $this->cyberpanel_hostname . ":8090/api/" . $action);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));

    return curl_exec($ch);

    }

    // Login as User (ERROR)

    // {
    // "loginStatus": "1",
    // "error_message": "Error if any.",
    // }

    public function user_login($username, $password){

    $action = 'loginAPI';

    $postdata = array(
    'username' => $username,
    'password' => $password
    );

    return $this->curl_result($action, $postdata);

    }

    // Some other function

    }


    $cyberpanel = new WP_Cyber_Panel('ip_of_server', 'admin_name', 'admin_pass');
    echo 'pre';
    var_dump( $cyberpanel->user_login('user_name', 'user_pass') );
    echo 'pre';
  • edited October 25
    That specific function does not take json encoded data, rest of them take json, lets take an example of verifyConn

    <?php
    class WP_Cyber_Panel{

    //Server credentials
    protected $cyberpanel_hostname = '';
    protected $admin_user = '';
    protected $admin_pass = '';

    public function __construct($hostname, $username, $password){

    $this->cyberpanel_hostname = $hostname;
    $this->admin_user = $username;
    $this->admin_pass = $password;

    }

    // curl function
    private function curl_result($action, $postdata){

    $postdata = json_encode($postdata);

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, "https://" . $this->cyberpanel_hostname . ":8090/api/" . $action);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));

    return curl_exec($ch);

    }

    // Login as User (ERROR)

    // {
    // "loginStatus": "1",
    // "error_message": "Error if any.",
    // }

    public function user_login($username, $password){

    $action = 'loginAPI';

    $postdata = array(
    'username' => $username,
    'password' => $password
    );

    return $this->curl_result($action, $postdata);

    }

    public function verify_login(){

    $action = 'verifyConn';

    $postdata = array(
    'adminUser' => $this->admin_user,
    'adminPass' => $this->admin_user
    );

    return $this->curl_result($action, $postdata);

    }

    // Some other function

    }


    $cyberpanel = new WP_Cyber_Panel('ip', 'user', 'pass');
    echo 'pre';
    var_dump( $cyberpanel->verify_login() );
    echo 'pre';

    ?>
  • Thanks, and what about set "Website limit = 0" for every new user register as default?
  • New user is created with "user" acl. So they cant create sites, does not matter what limit is set.
  • I mean, still admin creates a site for the customer, but each customer has many sites different . Actually, just setting websie limit = 0 (unlimited number of sites for user) is fine at CyberPanel, but I want to control via api, currently api does not support this, so I want to set websie limit = 0 as the default, in the first time create user . So admin then can create multiple sites for each user via api without logging in.

    May you help me how can do this?
    Many thanks!
  • in /api/createWebsite I can add option to supply website limit if you want. As this is where user is created.
  • I wait for the next version with more api. Thanks!
  • @wordpressuser

    I've added another option to this call -> https://cyberpanel.docs.apiary.io/#reference/website-functions/create-website

    parameter name is websitesLimit. If you don't set this value, default will be 1. This value will appear in v1.9.2.
  • edited October 27
    Thanks, and a few changes to User home page that I think are great.
    https://i.imgur.com/WuqqDNc.png
  • @CyberPanel
    please add option to select acl during user creation via api. for example we want to create user with different acl not using 'user'
  • @CyberPanel I believe this wasnt added to API yet? I am trying with 1.9.2 unfortunately its not working. Tried with Python, curl, PHP wasnt successful with any.

Sign In or Register to comment.
CyberPanel Discord

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!