package de.snailshell.consensus.demo.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import de.snailshell.consensus.demo.Constants;
import de.uka.ipd.consensus.impl.UserImpl;

/**
 * @author Thomas Much
 * @version 2006-06-14
 */
public class AccountAction extends BasisAction {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		if (!isUserLoggedOn(request)) {
			return mapping.findForward( Constants.MAPPING_FAILURE );			
		}

		UserImpl user = (UserImpl)this.getUser(request);

		((DynaActionForm)form).set("vorname",user.getFirstname());
		((DynaActionForm)form).set("nachname",user.getLastname());
		((DynaActionForm)form).set("email",user.getEmail());
		((DynaActionForm)form).set("comment",user.getComment());
		((DynaActionForm)form).set("altespasswort","");
		((DynaActionForm)form).set("neuespasswort1","");
		((DynaActionForm)form).set("neuespasswort2","");

		return mapping.findForward( Constants.MAPPING_SUCCESS );
	}
}
