diff --git a/reset-pass/account-validator-impl/src/bundle/acknowledge_passwordReset.xml b/reset-pass/account-validator-impl/src/bundle/acknowledge_passwordReset.xml new file mode 100644 index 000000000000..278dbacb140b --- /dev/null +++ b/reset-pass/account-validator-impl/src/bundle/acknowledge_passwordReset.xml @@ -0,0 +1,9 @@ + + + +${localSakaiName}: Your password has been changed successfully +Your password for ${localSakaiName} has been changed successfully. If you did not change your password, please contact ${emailSupport} + + + + diff --git a/reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java b/reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java index 46373f15d099..97e6d10f1c45 100644 --- a/reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java +++ b/reset-pass/account-validator-impl/src/java/org/sakaiproject/accountvalidator/logic/impl/ValidationLogicImpl.java @@ -85,6 +85,7 @@ public class ValidationLogicImpl implements ValidationLogic { private static final String TEMPLATE_KEY_PASSWORDRESET = "validate.passwordreset"; private static final String TEMPLATE_KEY_DELETED = "validate.deleted"; private static final String TEMPLATE_KEY_REQUEST_ACCOUNT = "validate.requestAccount"; + private static final String TEMPLATE_KEY_ACKNOWLEDGE_PASSWORD_RESET = "acknowledge.passwordReset"; private static final int VALIDATION_PERIOD_MONTHS = -36; private static Log log = LogFactory.getLog(ValidationLogicImpl.class); @@ -100,6 +101,7 @@ public void init(){ loadTemplate("validate_newPassword.xml", TEMPLATE_KEY_PASSWORDRESET); loadTemplate("validate_deleted.xml", TEMPLATE_KEY_DELETED); loadTemplate("validate_requestAccount.xml", TEMPLATE_KEY_REQUEST_ACCOUNT); + loadTemplate("acknowledge_passwordReset.xml", TEMPLATE_KEY_ACKNOWLEDGE_PASSWORD_RESET); //seeing the GroupProvider is optional we need to load it here if (groupProvider == null) { diff --git a/reset-pass/account-validator-tool/pom.xml b/reset-pass/account-validator-tool/pom.xml index 7508511a90cd..99f34c0f2655 100644 --- a/reset-pass/account-validator-tool/pom.xml +++ b/reset-pass/account-validator-tool/pom.xml @@ -42,6 +42,10 @@ org.sakaiproject.entitybroker entitybroker-utils + + org.sakaiproject.emailtemplateservice + emailtemplateservice-api + org.sakaiproject.kernel diff --git a/reset-pass/account-validator-tool/src/java/org/sakaiproject/accountvalidator/tool/otp/AcountValidationLocator.java b/reset-pass/account-validator-tool/src/java/org/sakaiproject/accountvalidator/tool/otp/AcountValidationLocator.java index 74cb23b7185d..421bd5fae28b 100644 --- a/reset-pass/account-validator-tool/src/java/org/sakaiproject/accountvalidator/tool/otp/AcountValidationLocator.java +++ b/reset-pass/account-validator-tool/src/java/org/sakaiproject/accountvalidator/tool/otp/AcountValidationLocator.java @@ -29,6 +29,7 @@ import org.sakaiproject.authz.api.SecurityAdvisor; import org.sakaiproject.authz.api.SecurityService; import org.sakaiproject.component.api.ServerConfigurationService; +import org.sakaiproject.emailtemplateservice.service.EmailTemplateService; import org.sakaiproject.entity.api.ResourcePropertiesEdit; import org.sakaiproject.entitybroker.DeveloperHelperService; import org.sakaiproject.entitybroker.EntityReference; @@ -42,9 +43,11 @@ import uk.org.ponder.messageutil.TargettedMessageList; import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; public class AcountValidationLocator implements BeanLocator { @@ -55,6 +58,8 @@ public class AcountValidationLocator implements BeanLocator { private Map delivered = new HashMap(); + private static final String TEMPLATE_KEY_ACKNOWLEDGE_PASSWORD_RESET = "acknowledge.passwordReset"; + private ValidationLogic validationLogic; public void setValidationLogic(ValidationLogic vl) { validationLogic = vl; @@ -108,6 +113,12 @@ public void setServerConfigurationService( this.serverConfigurationService = serverConfigurationService; } + private EmailTemplateService emailTemplateService; + public void setEmailTemplateService(EmailTemplateService emailTemplateService) + { + this.emailTemplateService = emailTemplateService; + } + public Object locateBean(String name) { Object togo = delivered.get(name); log.debug("Locating ValidationAccount: " + name); @@ -174,6 +185,8 @@ public ValidationAccount getAccount() { public String validateAccount() { log.debug("Validate Account"); + List userReferences = new ArrayList(); + for (Iterator it = delivered.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); @@ -303,6 +316,8 @@ public SecurityAdvice isAllowed(String userId, String function, String reference developerHelperService.fireEvent("accountvalidation.validated", u.getReference()); validationLogic.save(item); + + userReferences.add(userDirectoryService.userReference(item.getUserId())); //log the user in @@ -339,6 +354,11 @@ public SecurityAdvice isAllowed(String userId, String function, String reference } + String supportEmail = serverConfigurationService.getString("support.email"); + Map replacementValues = new HashMap(); + replacementValues.put("emailSupport", supportEmail); + emailTemplateService.sendRenderedMessages(TEMPLATE_KEY_ACKNOWLEDGE_PASSWORD_RESET, userReferences, replacementValues, supportEmail, supportEmail); + return "success"; } diff --git a/reset-pass/account-validator-tool/src/webapp/WEB-INF/requestContext.xml b/reset-pass/account-validator-tool/src/webapp/WEB-INF/requestContext.xml index 32d8f706b1df..72868b3d5c2d 100644 --- a/reset-pass/account-validator-tool/src/webapp/WEB-INF/requestContext.xml +++ b/reset-pass/account-validator-tool/src/webapp/WEB-INF/requestContext.xml @@ -74,6 +74,7 @@ +