What is the value of action.login in your TurbineResources.properties file?
> -----Original Message----- > From: Lauri Svan [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 06, 2003 10:07 AM > To: [EMAIL PROTECTED] > Subject: Storing temporary data in login > > > Hi, > > I have been trying to implement a simple web shop having > shopping carts, e-mail confirmations and such. So far Turbine > has met most of the requirements. However, I have found one > problem that I have difficulties in overcoming. > > Majority of the pages (i.e. picking items to the shopping > cart bean) require no authorization. But when checking out, > the user should be prompted for user name and password. I > have implemented these by extending TurbineUser with my own > class. However, when logging in, the cart object stored with > RunData.setTemp() is lost. I tried to fix this by extending > the LoginAction used in authentication with my own class, > which stores shopping cart in a temporary variable before > calling super.doPerform(), and setting the cart back after > the authentication is complete. This works fine if the > authentication was ok, but somehow the cart is lost if > authentication failed. > > What could be the cause of this problem and how could I fix it? > > > The code snippet for extending the user is as follows: > > > package com.ls.webshop.modules.actions; > import org.apache.turbine.util.TurbineException; > import org.apache.turbine.services.resources.TurbineResources; > > import org.apache.turbine.TurbineConstants; > import org.apache.turbine.modules.actions.*; > import org.apache.turbine.util.Log; > import org.apache.turbine.util.RunData; > import org.apache.turbine.services.resources.TurbineResources; > import org.apache.turbine.services.security.TurbineSecurity; > import org.apache.turbine.om.security.User; > import org.apache.turbine.util.security.DataBackendException; > import org.apache.turbine.util.security.TurbineSecurityException; > > import com.ls.webshop.util.business.*; > import com.ls.webshop.om.WebshopUser; > > /** > * Logins an user, with the meaning of not to clear the > session prior to login. > * Default configurations invalidate the session prior to > executing doPerform. > * To maintain a shopping cart in login, the login must be > done otherwise, and > * the cart should be saved in a temporary variable prior > logging in. */ public class ExtendedLoginUser extends LoginUser { > > public void doPerform(RunData data) throws Exception { > /* Fetch the shopping cart of the user, use a new one if > not exists */ > WebshopUser user = (WebshopUser) data.getUser(); > ShoppingCart cart = (ShoppingCart) user.getTemp("cart", > new > ShoppingCart()); > > System.err.println("Authenticate"); > try { > /* Invalidate the current session to provide a means for > logging in */ > data.removeUserFromSession(); > super.doPerform(data); > } > catch(Exception e) { > /* user = (WebshopUser) data.getUser(); > user.setTemp("cart", cart); > throw e; */ > } > user = (WebshopUser) data.getUser(); > if (user != null) > user.setTemp("cart", cart); > System.err.println("Setting next template"); > > /* Check whether services.webshop.navigation.redirect.key > parameter exists. If so, redirect there */ > String nextTemplate = > > data.getParameters().get(TurbineResources.getString("services. webshop.navigation.redirect.key")); > if (nextTemplate != null) > data.setScreenTemplate(nextTemplate); > } > } > > Regards, > > Lauri Svan > [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
