Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r9004121c5aab7ccdf967fa5ceef247c8950e92f8 -r666fb04f2c0a0fba205a3efb7c0fc64680aeefcc --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 9004121c5aab7ccdf967fa5ceef247c8950e92f8) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 666fb04f2c0a0fba205a3efb7c0fc64680aeefcc) @@ -202,13 +202,14 @@ label.forgot.password.username =Check Username forgot.password.email.subject =LAMS server - Forgot password response forgot.password.email.body =Click the link below to and it will take you to a page where you can change your password. -forgot.password.email.sent =An email has been sent to your email address. +forgot.password.email.sent =An email has been sent to your email address: error.forgot.password.email =Please enter an email address. error.forgot.password.username =Please enter a username. error.user.not.found =Unable to find the username in LAMS. Please check your username and try again. -error.email.not.found =Unable to find a user that matches the given email. Please check your email and try again. +error.email.not.found =Unable to find a user that matches the given email. Please check your email address and try again. error.multiple.emails =There are multiple users in LAMS with the given email. Email could not be sent. Please try again using your username, or contact your System Administrator. error.support.email.not.set =Email could not be sent. The LAMS server has not been configured to handle emails. Please contact your System Administrator. error.password.request.expired =This request for a new password has expired. Please click the "Forgot your Password" link again to make a new request. +error.email.not.sent =Server failed to send email to recipient. Please contact your System Administrator. #======= End labels: Exported 199 labels for en AU ===== Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r626edac7e22ded609d12f8df41fd7f776c129779 -r666fb04f2c0a0fba205a3efb7c0fc64680aeefcc --- lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 626edac7e22ded609d12f8df41fd7f776c129779) +++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 666fb04f2c0a0fba205a3efb7c0fc64680aeefcc) @@ -197,14 +197,19 @@ label.ok =OK title.forgot.password =LAMS :: Forgot Password label.forgot.password.confirm =Password Request -label.forgot.password.instructions =Please enter your user name and email below. An email will be sent to you shortly with a link that will allow you to change your password. If you do not know your email address in LAMS, please contact your System Administrator. +label.forgot.password.instructions =Please enter your user name or email below. An email will be sent to you shortly with a link that will allow you to change your password. You only need to enter one value.

If you do not know your email address in LAMS, please contact your System Administrator. +label.forgot.password.email =Check Email +label.forgot.password.username =Check Username forgot.password.email.subject =LAMS server - Forgot password response forgot.password.email.body =Click the link below to and it will take you to a page where you can change your password. -forgot.password.email.sent =An email has been sent to your email address. +forgot.password.email.sent =An email has been sent to your email address: +error.forgot.password.email =Please enter an email address. +error.forgot.password.username =Please enter a username. error.user.not.found =Unable to find the username in LAMS. Please check your username and try again. -error.email.does.not.match =The email address does not match your saved email address. Please try again. +error.email.not.found =Unable to find a user that matches the given email. Please check your email address and try again. +error.multiple.emails =There are multiple users in LAMS with the given email. Email could not be sent. Please try again using your username, or contact your System Administrator. error.support.email.not.set =Email could not be sent. The LAMS server has not been configured to handle emails. Please contact your System Administrator. error.password.request.expired =This request for a new password has expired. Please click the "Forgot your Password" link again to make a new request. +error.email.not.sent =Server failed to send email to recipient. Please contact your System Administrator. - #======= End labels: Exported 199 labels for en AU ===== Index: lams_central/src/java/org/lamsfoundation/lams/web/ForgotPasswordServlet.java =================================================================== diff -u -rce4cbebf1be445b929c868d9de9450b00e5aefa0 -r666fb04f2c0a0fba205a3efb7c0fc64680aeefcc --- lams_central/src/java/org/lamsfoundation/lams/web/ForgotPasswordServlet.java (.../ForgotPasswordServlet.java) (revision ce4cbebf1be445b929c868d9de9450b00e5aefa0) +++ lams_central/src/java/org/lamsfoundation/lams/web/ForgotPasswordServlet.java (.../ForgotPasswordServlet.java) (revision 666fb04f2c0a0fba205a3efb7c0fc64680aeefcc) @@ -5,6 +5,7 @@ import java.util.Calendar; import java.util.Properties; import java.util.List; +import java.net.URLEncoder; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -54,11 +55,13 @@ public static String SUCCESS_CHANGE_PASS = "heading.password.changed.screen"; public static String EMAIL_NOT_FOUND = "error.email.not.found"; public static String MULTIPLE_EMAILS = "error.multiple.emails"; + public static String EMAIL_FAILED = "error.email.not.sent"; - public static int MILLISECONDS_IN_A_DAY = 86400000; + private static int MILLISECONDS_IN_A_DAY = 86400000; private static String STATE = "&state="; private static String LANGUAGE_KEY = "&languageKey="; + private static String EMAIL_SENT = "&emailSent="; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException @@ -81,7 +84,7 @@ } - handleEmailRequest(findByEmail, param, response); + handleEmailRequest(findByEmail, param.trim(), response); } else if (method.equals("requestPasswordChange")) { @@ -122,7 +125,7 @@ String SMPTServer = Configuration.get("SMTPServer"); String supportEmail = Configuration.get("LamsSupportEmail"); - + User user = null; if (SMPTServer==null||SMPTServer.equals("")||supportEmail==null||supportEmail.equals("")) { @@ -134,10 +137,7 @@ WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()); IUserManagementService userService = (IUserManagementService) ctx.getBean("userManagementService"); MessageService messageService = (MessageService)ctx.getBean("centralMessageService"); - - User user = null; - // get the user by email or login if (!findByEmail) { @@ -207,33 +207,46 @@ catch (AddressException e) { // failure handling - log.debug(e); - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + log.error("Problem sending email to: " +user.getLogin()+ " with email: " + user.getEmail(), e); + //response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + languageKey = EMAIL_FAILED; + success = 0; } catch (MessagingException e) { // failure handling - log.debug(e); - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + log.error("Problem sending email to: " +user.getLogin()+ " with email: " + user.getEmail(), e); + //response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + languageKey = EMAIL_FAILED; + success = 0; } catch (Exception e) { // failure handling - log.debug(e); - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + log.error("Problem sending email to: " +user.getLogin()+ " with email: " + user.getEmail(), e); + languageKey = EMAIL_FAILED; + success = 0; + //response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } + + } } - - - response.sendRedirect(Configuration.get("ServerURL") + "forgotPasswordProc.jsp?" + + String redirectStr = Configuration.get("ServerURL") + "forgotPasswordProc.jsp?" + STATE + success + LANGUAGE_KEY + - languageKey); + languageKey; + + if (success==1 && user.getEmail()!=null) + { + redirectStr += EMAIL_SENT +java.net.URLEncoder.encode(user.getEmail(), "UTF-8"); + } + response.sendRedirect(redirectStr); + } /** @@ -245,7 +258,7 @@ { int success=0; String languageKey = ""; - + if (key==null||key.equals("")||newPassword==null||newPassword.equals("")) { response.sendError(HttpServletResponse.SC_BAD_REQUEST); @@ -278,7 +291,8 @@ STATE + success + LANGUAGE_KEY + - languageKey); + languageKey + ); } /**