我必须将PrestaShop 1.5与预先存在的symfony应用程序集成。
通过webservices,我可以使数据库保持同步,这样用户就可以在PrestaShop和应用程序软件上使用相同的数据进行登录。现在我要确保登录应用程序时,用户是自动登录到PrestaShop平台的。
你能帮帮我吗?
发布于 2017-12-21 19:56:01
我不知道你是否还在寻找解决方案,但实际上是有办法的。
请确保这是一个安全的登录。
由于您授予了对所有prestashop数据的访问权限,因此一定要确保登录非常安全。我已经能够使用PHP
重新创建它,我认为通过添加一些内容,您就能够以您想要的方式重新创建它。把它看作是一个指导方针。
要使用prestashop you服务创建登录系统,您需要三样东西
通过webservice访问customers表COOKIE_KEY,在app/config -> parameters.php::'cookie_key‘=>’12321test‘中定义;使用PHP的一些经验第一件事是从webservice获取customers表。
// code placeholder
require_once('./../PSWebServiceLibrary.php');
/**
* get information from PrestaShop
*/
$webService = new PrestaShopWebservice($url, $key, $debug);
$COOKIE_KEY = 'CookieKey';
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];
$optUser = array(
'resource' => 'customers',
'filter[email]' => '[' . $email . ']',
'display' => '[id,email,lastname,firstname,passwd]'
);
$resultUser = ($webService->get($optUser));
$json = json_encode($resultUser);
第二件也是最重要的一件事是检查用户输入
// code placeholder
foreach ($resultUser->customers->customer as $info) {
// Prestashop uses the cookie_key in combination with a salt key. To check the password use the php function: password_verify();
$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'] = 'succes';
$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);
}
}
这是如何将问题重现到一个有效的示例中。
我使用的是设置一个cookie
并检查它是否存在!
希望这能有所帮助!
https://stackoverflow.com/questions/19980572
复制相似问题