Skip to content

Commit

Permalink
Merge pull request sakaiproject#777 from bbailla2/SAK-29614
Browse files Browse the repository at this point in the history
SAK-29614: Send an acknowledgement email after a successful password reset
  • Loading branch information
bjones86 committed Jul 2, 2015
2 parents 5404cdd + 0fc4576 commit 9630543
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<emailTemplates>
<emailTemplate>
<subject>${localSakaiName}: Your password has been changed successfully</subject>
<message>Your password for ${localSakaiName} has been changed successfully. If you did not change your password, please contact ${emailSupport}
</message>
<locale></locale>
</emailTemplate>
</emailTemplates>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions reset-pass/account-validator-tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<groupId>org.sakaiproject.entitybroker</groupId>
<artifactId>entitybroker-utils</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.emailtemplateservice</groupId>
<artifactId>emailtemplateservice-api</artifactId>
</dependency>

<dependency>
<groupId>org.sakaiproject.kernel</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -55,6 +58,8 @@ public class AcountValidationLocator implements BeanLocator {

private Map<String, Object> delivered = new HashMap<String, Object>();

private static final String TEMPLATE_KEY_ACKNOWLEDGE_PASSWORD_RESET = "acknowledge.passwordReset";

private ValidationLogic validationLogic;
public void setValidationLogic(ValidationLogic vl) {
validationLogic = vl;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -174,6 +185,8 @@ public ValidationAccount getAccount() {
public String validateAccount() {
log.debug("Validate Account");

List<String> userReferences = new ArrayList<String>();

for (Iterator<String> it = delivered.keySet().iterator(); it.hasNext();) {

String key = (String) it.next();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -339,6 +354,11 @@ public SecurityAdvice isAllowed(String userId, String function, String reference

}

String supportEmail = serverConfigurationService.getString("support.email");
Map<String, String> replacementValues = new HashMap<String, String>();
replacementValues.put("emailSupport", supportEmail);
emailTemplateService.sendRenderedMessages(TEMPLATE_KEY_ACKNOWLEDGE_PASSWORD_RESET, userReferences, replacementValues, supportEmail, supportEmail);

return "success";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<property name="developerHelperService" ref="org.sakaiproject.entitybroker.DeveloperHelperService"/>
<property name="messageLocator" ref="messageLocator"/>
<property name="serverConfigurationService" ref="org.sakaiproject.component.api.ServerConfigurationService"/>
<property name="emailTemplateService" ref="org.sakaiproject.emailtemplateservice.service.EmailTemplateService" />
</bean>

<bean name="claimLocator" class="org.sakaiproject.accountvalidator.tool.otp.ClaimLocator" >
Expand Down

0 comments on commit 9630543

Please sign in to comment.