arleyhr Posted January 8, 2017 Share Posted January 8, 2017 How to can I login customer via webservice in Prestashop 1.7 In Prestashop 1.6(In 1.7 not working): define('_COOKIE_KEY_', 'OXFQDX3YYM8MJH1RYGAQHH2LX79ZNRX'); $md5_password = md5(_COOKIE_KEY_+password); http://yourdomainname.com/api/customers/ ?filter[email][email protected] &filter[passwd]=$md5_password Link to comment Share on other sites More sharing options...
arleyhr Posted January 8, 2017 Author Share Posted January 8, 2017 (edited) My solution: check password with PHP: 1) Get customer by email: http://domain.com/api/customers?filter[email][email protected] 2) verify "passwd": password_verify(the_input_password, passwd); PASSWORD_VERIFY DOCS: http://php.net/manual/es/function.password-verify.php Edited January 9, 2017 by arleyhr (see edit history) Link to comment Share on other sites More sharing options...
mastlucas Posted March 16, 2021 Share Posted March 16, 2021 (edited) Hello! I need to get a user of my website to login to the prestashop ecommerce. With the APi I managed to validate the email and password, now I only need that when I refresh the ecomerce, I appear logged in. Any suggestion? My version prestashop is: 1.7.6.4 My code is the following //--------------Login // get information from PrestaShop $ webService = new PrestaShopWebservice ('https://www.xxxxx.com/', 'XXXXXXXXXXXXXXXXXXXX', false); $ email = '[email protected]'; // $ _REQUEST ['email']; $ password = 'XXXXX'; // $ password = $ _REQUEST ['password']; $ optUser = array ( 'resource' => 'customers', 'filter [email]' => '['. $ email. ']', 'display' => '[id, email, lastname, firstname, passwd]' ); $ resultUser = ($ webService-> get ($ optUser)); foreach ($ resultUser-> customers-> customer as $ info) { if (password_verify ($ password, $ info-> passwd) == true) { $ response = array (); $ response ['status'] = 'succes'; $ response ['message'] = "You did it!"; setcookie ("userId", $ info-> id); $ _SESSION ['user'] = $ email; header ('Content-type: application / json'); echo json_encode ($ response); echo '<br>'. $ info-> passwd; echo '<br>'. $ cook; } else { $ response = array (); $ response ['status'] = 'error'; $ response ['message'] = 'Wrong password'; header ('Content-type: application / json'); echo json_encode ($ response); } } Edited March 16, 2021 by mastlucas (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now