Jump to content

Creating a customer login using the prestashop webservice


Deathstorm

Recommended Posts

Hi everyone,

I'm currently working on an application that uses the prestashop webservice. And after creating functionallities like: customer creation, product creation, update functions and other function's i've stumbled upon a problem. I'm trying to create or "recreate" the login function from Presatashop. I would like to give registered customers from the customers table and that are in a special group the possibility to login on the webservice area. So i've been trying some things but i can't quite get to the perfect solution that works for me.

 

So my question summarized: How am i able to create a customer login script on my webservice application. Things i've tried are:

 

<?php

require_once('./PSWebServiceLibrary.php');

/**
 * get information from PrestaShop
 */
error_reporting(E_ALL);
ini_set('display_errors', 1);

$webService = new PrestaShopWebservice($url, $key, $debug);

$COOKIE_KEY = 'Cookie_key';
$email = $_REQUEST['email'];
$password = md5('Cookie_key' . $_REQUEST['password']);

$opt = array(
    'resource'       => 'customers',
    'filter[email]'  => '['.$email.']',
    'filter[passwd]'  => '['.$password.']',
    'display' => '[email,lastname,firstname, passwd]'
);

$result = ($webService->get( $opt ));

$json = json_encode($result);

echo ($json);

$passwordCheck = array(
    'resource'       => 'customers',
    'filter[email]'  => '['.$email.']',
    'display' => '[passwd]'
);

$resultPass = ($webService->get( $passwordCheck ));

$chopPass  = $resultPass->children()->children()->children();
$jsonPass = json_encode($chopPass);

print_r($jsonPass);

if(password_verify($password, 'hashInDB')) {
    echo "Succes";
} else {
    echo "failed!";
}

Thanks in advance!

Link to comment
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
×
×
  • Create New...