Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if($_POST['action'] == 'call_this') {
- checkUser();
- }
- function checkUser() {
- $url = 'myshopurl'; //code uses actual url
- $key = 'mykey'; //code uses actual key
- $debug = true;
- require_once('./PSWebServiceLibrary.php');
- $webService = new PrestaShopWebservice($url, $key, $debug);
- $COOKIE_KEY = 'mycookiekey'; //code uses actual cookie key
- $password = $_REQUEST['password'];
- $email = $_REQUEST['email'];
- $optUser = array(
- 'resource' => 'customers',
- 'filter[email]' => '[' . $email . ']',
- 'display' => '[id,email,lastname,firstname,passwd]'
- );
- $resultUser = ($webService->get($optUser));
- $json = json_encode($resultUser);
- echo $json;
- foreach ($resultUser->customers->customer as $info) {
- $salt = substr($info->passwd, strrpos($info->passwd, ':') + 1, 2);
- $ZCpassword = md5($COOKIE_KEY . $password) . ':' . $salt;
- // Check if password comparison is true or false
- if (password_verify($password, $info->passwd) == true) {
- session_start();
- $response = array();
- $response['status'] = 'success';
- $response['message'] = "You did it!";
- setcookie("userId", $info->id);
- header('Content-type: application/json');
- echo json_encode($response);
- } else {
- $response = array();
- $response['status'] = 'error';
- $response['message'] = 'Wrong password';
- header('Content-type: application/json');
- echo json_encode($response);
- }
- }
Add Comment
Please, Sign In to add comment