Jump to content

Edit History

0dp

0dp


typo

Using the Prestashop webservice and PSWebServiceLibrary to create a new user registration I noticed that prestashop allows registration of users having the same email.

    // Create user in prestashop
    $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
    $xmlResponse = $webService->get(array('url' => PS_SHOP_PATH.'/api/customers?schema=blank'));
    $customerXML = $xmlResponse->customer[0];
    
    $customerXML->id_lang = $locale_id;
    $customerXML->lastname = $lastname;
    $customerXML->firstname = $firstname;
    $customerXML->email = $email;
    $customerXML->passwd = $password;
    $customerXML->id_gender = $gender;
    $customerXML->birtday = $birthday;

    $customerXML->active = '1';
    $customerXML->associations->groups->group->id = GROUP_ID;
     
    try {
        $addedCustomerResponse = $webService->add([
            'resource' => 'customers',
            'postXml' => $xmlResponse->asXML(),
        ]);
        $customerXML = $addedCustomerResponse->customer[0];
        echo sprintf("Successfully create customer with ID: %s", (string) $customerXML->id);
    } catch (PrestaShopWebserviceException $e) {
        // if user exist, throw error that triggers frontend error
    	echo json_encode(array(
        	'error' => array(
            	'msg' => $e->getMessage(),
            	'code' => $e->getCode(),
        	),
    	));
    }

 

Firstly, I don't understand how and why this is even possible?

Secondly, does Prestashops webservice allow for a way to check if the email is already in use?

0dp

0dp

Using the Prestashop webservice and PSWebServiceLibrary to create a new user registration I noticed that prestashop allows registration of users having the same email.

    // Create user in prestashop
    $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
    $xmlResponse = $webService->get(array('url' => PS_SHOP_PATH.'/api/customers?schema=blank'));
    $customerXML = $xmlResponse->customer[0];
    
    $customerXML->id_lang = $locale_id;
    $customerXML->lastname = $lastname;
    $customerXML->firstname = $firstname;
    $customerXML->email = $email;
    $customerXML->passwd = $password;
    $customerXML->id_gender = $gender;
    $customerXML->birtday = $birthday;

    $customerXML->active = '1';
    $customerXML->associations->groups->group->id = GROUP_ID;
     
    try {
        $addedCustomerResponse = $webService->add([
            'resource' => 'customers',
            'postXml' => $xmlResponse->asXML(),
        ]);
        $customerXML = $addedCustomerResponse->customer[0];
        echo sprintf("Successfully create customer with ID: %s", (string) $customerXML->id);
    } catch (PrestaShopWebserviceException $e) {
        // if user exist, throw error that triggers frontend error...HOW?
    	echo json_encode(array(
        	'error' => array(
            	'msg' => $e->getMessage(),
            	'code' => $e->getCode(),
        	),
    	));
    }

 

Firstly, I don't understand how and why this is even possible?

Secondly, does Prestashops webservice allow for a way to check if the email is already in use?

×
×
  • Create New...