01: /*
02: * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
03: *
04: * This file is part of TransferCM.
05: *
06: * TransferCM is free software; you can redistribute it and/or modify it under the
07: * terms of the GNU General Public License as published by the Free Software
08: * Foundation; either version 2 of the License, or (at your option) any later
09: * version.
10: *
11: * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
12: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14: * details.
15: *
16: * You should have received a copy of the GNU General Public License along with
17: * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
18: * Fifth Floor, Boston, MA 02110-1301 USA
19: */
20:
21: package com.methodhead.reg;
22:
23: import java.io.Serializable;
24: import javax.servlet.http.HttpServletRequest;
25:
26: import org.apache.struts.action.ActionMapping;
27: import org.apache.struts.action.ActionErrors;
28: import org.apache.struts.action.ActionError;
29: import org.apache.struts.validator.DynaValidatorForm;
30: import com.methodhead.reg.User;
31: import com.methodhead.reg.RegPolicy;
32: import com.methodhead.reg.Role;
33: import com.methodhead.util.StrutsUtil;
34: import com.methodhead.sitecontext.SiteContext;
35: import java.util.Iterator;
36:
37: public class SendPasswordForm extends DynaValidatorForm implements
38: Serializable {
39:
40: public ActionErrors validate(ActionMapping mapping,
41: HttpServletRequest request) {
42:
43: ActionErrors errors = super .validate(mapping, request);
44:
45: if (errors.isEmpty()) {
46:
47: //
48: // create a user
49: //
50: RegPolicy policy = (RegPolicy) StrutsUtil
51: .getPolicy(mapping);
52: User user = policy.newRegUser();
53:
54: //
55: // does the user exist at all?
56: //
57: if (!user.loadForLogin((String) get("email"))) {
58: errors.add("email", new ActionError(
59: "reg.sendpassword.noSuchUser"));
60: }
61: }
62:
63: return errors;
64: }
65: }
|