Jump to content

Webservice allow creation of users with same email


0dp
 Share

Recommended Posts

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?

Edited by 0dp
typo (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More