Fixed: Error on createShoppingListItem when adding item to cart as anonymous
(OFBIZ-5157)
It can be reproduced by setting the product_store field autoSaveCart to 'Y'
(In Store 9000 for the demo-data). Then the error occurs upon the first visit of
the ecommerce-site, provided the user is not logged in.
First Visit: no userLogin
OFBiz wants to autosave list
saving list requires userLogin (forsecuritycheck)
result: error
Thanks: Mirko Vogelsmeier for report, Benjamin Jugl for the fix
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1848263 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+11
-12
@@ -444,25 +444,24 @@ public class ShoppingListEvents {
|
||||
Delegator delegator = (Delegator) request.getAttribute("delegator");
|
||||
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
|
||||
GenericValue productStore = ProductStoreWorker.getProductStore(request);
|
||||
|
||||
if (!ProductStoreWorker.autoSaveCart(productStore)) {
|
||||
// if auto-save is disabled just return here
|
||||
return "success";
|
||||
}
|
||||
|
||||
HttpSession session = request.getSession();
|
||||
ShoppingCart cart = ShoppingCartEvents.getCartObject(request);
|
||||
|
||||
// safety check for missing required parameter.
|
||||
if (cart.getWebSiteId() == null) {
|
||||
cart.setWebSiteId(WebSiteWorker.getWebSiteId(request));
|
||||
}
|
||||
|
||||
// locate the user's identity
|
||||
GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
|
||||
if (userLogin == null) {
|
||||
userLogin = (GenericValue) session.getAttribute("autoUserLogin");
|
||||
}
|
||||
|
||||
if (!ProductStoreWorker.autoSaveCart(productStore) || userLogin == null) {
|
||||
// if auto-save is disabled or there is still no userLogin just return here
|
||||
return "success";
|
||||
}
|
||||
|
||||
// safety check for missing required parameter.
|
||||
if (cart.getWebSiteId() == null) {
|
||||
cart.setWebSiteId(WebSiteWorker.getWebSiteId(request));
|
||||
}
|
||||
|
||||
// find the list ID
|
||||
String autoSaveListId = cart.getAutoSaveListId();
|
||||
@@ -650,7 +649,7 @@ public class ShoppingListEvents {
|
||||
}
|
||||
|
||||
// clear the auto-save info
|
||||
if (ProductStoreWorker.autoSaveCart(delegator, productStoreId)) {
|
||||
if (userLogin!= null && ProductStoreWorker.autoSaveCart(delegator, productStoreId)) {
|
||||
if (UtilValidate.isEmpty(autoSaveListId)) {
|
||||
try {
|
||||
Map<String, Object> listFields = UtilMisc.<String, Object>toMap("userLogin", userLogin, "productStoreId", productStoreId, "shoppingListTypeId", "SLT_SPEC_PURP", "listName", PERSISTANT_LIST_NAME);
|
||||
|
||||
Reference in New Issue
Block a user