Zet4 Posted January 28, 2011 Share Posted January 28, 2011 Hi! is possible login from other webpage? i have one webpage that check the email and pass of prestashop and redirect to prestashop´s shop, but the user is not logging and i want that the user login in my webpage and remain login in prestashop, is possible? how? Link to comment Share on other sites More sharing options...
shokinro Posted January 28, 2011 Share Posted January 28, 2011 By default you are not able to do that.You need to add some code to PrestaShop to handle this. The new should do following job1. Identify redirect source is coming from the page you mentioned out of PrestaShop Need high security checking to provent hack attack. It is very important.2. Use user information from reditect source to log in automatically. The information need to be encrypted for security.I think you must do it very carefully. Link to comment Share on other sites More sharing options...
Zet4 Posted January 28, 2011 Author Share Posted January 28, 2011 By default you are not able to do that.You need to add some code to PrestaShop to handle this. The new should do following job1. Identify redirect source is coming from the page you mentioned out of PrestaShop Need high security checking to provent hack attack. It is very important.2. Use user information from reditect source to log in automatically. The information need to be encrypted for security.I think you must do it very carefully. Hi! thank you for your reply, mmm i know that i have to add source to the prestashop.the point one i understand, and i have controlled by this http://www.jcryption.org/.And point 2, i dont understand that you want say "Use user information from reditect source to log in automatically." how call the metod that picks the params? from index? Link to comment Share on other sites More sharing options...
shokinro Posted January 28, 2011 Share Posted January 28, 2011 And point 2, i dont understand that you want say “Use user information from reditect source to log in automatically.” At least you must pass which user is logged in, right? You can pass this information by POST (post in HTML form) or GET (in URL parameters) from redirect source.Then at PrestaShop, you can retrieve this information from $_POST or $_GETData passed must be encrypted, and both side must use the same encrypt method. Link to comment Share on other sites More sharing options...
Zet4 Posted January 28, 2011 Author Share Posted January 28, 2011 And point 2, i dont understand that you want say “Use user information from reditect source to log in automatically.” At least you must pass which user is logged in, right? You can pass this information by POST (post in HTML form) or GET (in URL parameters) from redirect source.Then at PrestaShop, you can retrieve this information from $_POST or $_GETData passed must be encrypted, and both side must use the same encrypt method. Yes, allthis i understand, and i have the source good, look.In my principal (no prestashop) i verify the email and password of DB prestashop, and if is ok, redirect to prestashop, and i receive the data in prestashop, but how login one user with this variables? What is the class that i should call? and where call? thank you! Link to comment Share on other sites More sharing options...
shokinro Posted January 28, 2011 Share Posted January 28, 2011 Please check the code in authentication.php page.Find out the part that after user input correct user name and password. You can just use the same code. (better the passed in user really exists and you really trust the redirect source) Link to comment Share on other sites More sharing options...
Zet4 Posted January 28, 2011 Author Share Posted January 28, 2011 Ok, i found this in authentication.php: include("authentication.php"); if (Tools::isSubmit('SubmitLogin')) { $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); if (empty($email)) $errors[] = Tools::displayError('e-mail address is required'); elseif (!Validate::isEmail($email)) $errors[] = Tools::displayError('invalid e-mail address'); elseif (empty($passwd)) $errors[] = Tools::displayError('password is required'); elseif (Tools::strlen($passwd) > 32) $errors[] = Tools::displayError('password is too long'); elseif (!Validate::isPasswd($passwd)) $errors[] = Tools::displayError('invalid password'); else { $customer = new Customer(); $authentication = $customer->getByEmail(trim($email), trim($passwd)); /* Handle brute force attacks */ sleep(1); if (!$authentication OR !$customer->id) $errors[] = Tools::displayError('authentication failed'); else { $cookie->id_customer = intval($customer->id); $cookie->customer_lastname = $customer->lastname; $cookie->customer_firstname = $customer->firstname; $cookie->logged = 1; $cookie->passwd = $customer->passwd; $cookie->email = $customer->email; if (Configuration::get('PS_CART_FOLLOWING') AND (empty($cookie->id_cart) OR Cart::getNbProducts($cookie->id_cart) == 0)) $cookie->id_cart = intval(Cart::lastNoneOrderedCart(intval($customer->id))); Module::hookExec('authentication'); if ($back = Tools::getValue('back')) Tools::redirect($back); Tools::redirect('my-account.php'); } } } then i modifiy $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); For my 2 variables $_GET or $_POST.But show this:Fatal error: Call to undefined method Customer::getByMd5() in D:\wamp\www\prestashop\authentication.php on line 10PS= i paste this code to index.php, is correct? or i should paste this source in another site? Link to comment Share on other sites More sharing options...
shokinro Posted January 28, 2011 Share Posted January 28, 2011 If you are using index.php page to accept redirection, you need include those code in index.php file.But you don't need to include authentication.php, instead, you need to include following.include(dirname(__FILE__).'/init.php');Maybe you need include some file else. I will have to be off line for a while. hope you will figure it out and get it one. You are almost there. By the way, it seems you are not encrypting user name and password, it is dangerous. I assume it just for test, you will do it when it put it to live. Link to comment Share on other sites More sharing options...
Zet4 Posted January 28, 2011 Author Share Posted January 28, 2011 If you are using index.php page to accept redirection, you need include those code in index.php file.But you don't need to include authentication.php, instead, you need to include following.include(dirname(__FILE__).'/init.php');Maybe you need include some file else. I will have to be off line for a while. hope you will figure it out and get it one. You are almost there. By the way, it seems you are not encrypting user name and password, it is dangerous. I assume it just for test, you will do it when it put it to live. Yes only is for test, dont worry, when i have the way for do this, then i encrypt the data.Now i delete "include authentication.php" and add init.php, but the page is white, dont work, but no show error (and i have errors on in config.inc.php)Then, should i use other script only for check this data and after redirect to index.php¿?Other question, what index should i modify? the prinicipal? or the index in my themes directory?Thank you very much! Link to comment Share on other sites More sharing options...
shokinro Posted January 28, 2011 Share Posted January 28, 2011 yes, I suggest to create a new page to auto log in process and then redirect to index page. that will be better.See here on how create a new PrestaShop pagesI also suggest to copy authentication.php to as new page and then remove unwanted code, that might be faster. Link to comment Share on other sites More sharing options...
Zet4 Posted January 28, 2011 Author Share Posted January 28, 2011 yes, I suggest to create a new page to auto log in process and then redirect to index page. that will be better.See here on how create a new PrestaShop pagesI also suggest to copy authentication.php to as new page and then remove unwanted code, that might be faster. Hey thank you!!! good information, now i go to work! Link to comment Share on other sites More sharing options...
Zet4 Posted January 28, 2011 Author Share Posted January 28, 2011 I retry and retry but not get that login from other web.. .I make other PHP file, with one tpl.. ok, but is the same that the index, i need check the same, logiun to the user with the data retrieve from before page, i need help please Link to comment Share on other sites More sharing options...
Zet4 Posted January 28, 2011 Author Share Posted January 28, 2011 Well, after of... much hours..... i get it this!!!!! put in this forum for other people, to the end is easy easy easy!!!!.Simply this:My form for login is this: ><form id="login_form" method="POST" action="../prestashop/authentication.php "> </pre> <table width="200" border="0" align="center">Email:<input type="text" name="email" id="email"/></td> Contraseña: <input type="password" name="passwd" id="passwd"/></td> <input type="submit" id="SubmitLogin" name="SubmitLogin" class="button" /> </table> <br> </fo Then, send the data to the file authentication.php with the two field name "email" and "passwd", and submit with id SubmitLogin (for call to this functionThank you shokinro for your help! Link to comment Share on other sites More sharing options...
mova Posted March 10, 2011 Share Posted March 10, 2011 Is possible give me all example ? Thanks Link to comment Share on other sites More sharing options...
Recommended Posts