ForgotPasswordForm.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* ===================================================================
  2. * ForgotPasswordForm.java
  3. *
  4. * Created Feb 11, 2005 8:28:35 PM
  5. *
  6. * Copyright (c) 2005 Matt Magoffin (spamsqr@msqr.us)
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  21. * 02111-1307 USA
  22. * ===================================================================
  23. * $Id: ForgotPasswordForm.java 28 2009-05-04 01:19:45Z msqr $
  24. * ===================================================================
  25. */
  26. package magoffin.matt.ieat.web;
  27. import javax.servlet.http.HttpServletRequest;
  28. import javax.servlet.http.HttpServletResponse;
  29. import magoffin.matt.ieat.AuthorizationException;
  30. import magoffin.matt.ieat.biz.BizContext;
  31. import magoffin.matt.ieat.util.LogonCommand;
  32. import org.springframework.validation.BindException;
  33. import org.springframework.web.servlet.ModelAndView;
  34. /**
  35. * Form controller for handling "forgot my password" process.
  36. *
  37. * @author Matt Magoffin (spamsqr@msqr.us)
  38. * @version $Revision: 28 $ $Date: 2009-05-04 13:19:45 +1200 (Mon, 04 May 2009) $
  39. */
  40. public class ForgotPasswordForm extends AbstractEatForm {
  41. @Override
  42. protected ModelAndView onSubmit(HttpServletRequest request,
  43. HttpServletResponse response, Object command, BindException errors)
  44. throws Exception {
  45. LogonCommand form = (LogonCommand)command;
  46. BizContext context = WebUtil.getBizContext(request, false);
  47. ModelAndView result = null;
  48. try {
  49. userBiz.forgotPassword(form.getLogin(),context);
  50. result = new ModelAndView(getSuccessView(),errors.getModel());
  51. } catch ( AuthorizationException e ) {
  52. errors.reject("error.unknown.login", "Authorization error.");
  53. result = showForm(request,response,errors);
  54. }
  55. return result;
  56. }
  57. }