Search code examples
phprestcs-cart

CS-Cart user login with rest api


I am trying to login user with CS-Cart Rest API.

I want to access to log in the user into Android Mobile Application. I have done the registration part but the login part is not working.

According to CS-Cart Documentation:

password - The value of this field is the md5 hash of the user password. Used only when creating and updating a user.

So, I can use the password field only to create or update the user, but i want to login. I tried with the database, but it won't work either, they use multiple encryption md5 with salt.

Function used by CS CART FOr the website:

$password = '';

if (strlen($user_data['password']) == 32) {
    $password = $user_data['password'];
} else {
    if (!isset($user_data['salt']) || empty($user_data['salt'])) {
        $password = md5($user_data['password']);
    } else {
        $password = fn_generate_salted_password($user_data['password'], $user_data['salt']);
    }
}

return $password;

Now I want to know if I can access and validate the user with the REST API, if not how can I validate the user, if email and password matches, then it will be logged in on my Android Application.

Thanks in Advance


Solution

  • As per their REST API documentation, you need to use the user API key alongwith their email to list users. You need to enable the api access and generate the api key from the admin panel. Customers->Administrators-> user account.

    please follow the link https://docs.cs-cart.com/latest/developer_guide/api/entities/users.html to know more...

    password Field: The value of this field is md5 hash of user password. Used only when creating and updating a user