I am trying to send Customers first name and lastname along with reseturl link.I have override sendForgotPasswordNotification()
in customerserviceImpl class by creating class under package com.mycompany.profile.forgotpassword.My forgotpassword class has following code
Code: Select all
package com.mycompany.profile.forgotpassword;
import org.apache.commons.lang.StringUtils;
import org.broadleafcommerce.common.security.util.PasswordUtils;
import org.broadleafcommerce.common.service.GenericResponse;
import org.broadleafcommerce.common.time.SystemTime;
import org.broadleafcommerce.profile.core.domain.Customer;
import org.broadleafcommerce.profile.core.domain.CustomerForgotPasswordSecurityToken;
import org.broadleafcommerce.profile.core.domain.CustomerForgotPasswordSecurityTokenImpl;
import org.broadleafcommerce.profile.core.service.CustomerServiceImpl;
import java.util.HashMap;
public class ForgotpasswordNotification extends CustomerServiceImpl {
@Override
public GenericResponse sendForgotPasswordNotification(String username, String resetPasswordUrl) {
System.out.println("Override Test");
GenericResponse response = new GenericResponse();
Customer customer = null;
if (username != null) {
customer = customerDao.readCustomerByUsername(username);
}
checkCustomer(customer,response);
if (! response.getHasErrors()) {
String token = PasswordUtils.generateTemporaryPassword(getPasswordTokenLength());
token = token.toLowerCase();
CustomerForgotPasswordSecurityToken fpst = new CustomerForgotPasswordSecurityTokenImpl();
fpst.setCustomerId(customer.getId());
fpst.setToken(passwordEncoder.encodePassword(token, null));
fpst.setCreateDate(SystemTime.asDate());
customerForgotPasswordSecurityTokenDao.saveToken(fpst);
HashMap<String, Object> vars = new HashMap<String, Object>();
vars.put("token", token);
if (!StringUtils.isEmpty(resetPasswordUrl)) {
if (resetPasswordUrl.contains("?")) {
resetPasswordUrl=resetPasswordUrl+"&token="+token;
} else {
resetPasswordUrl=resetPasswordUrl+"?token="+token;
}
}
vars.put("resetPasswordUrl", resetPasswordUrl);
vars.put("Username", customer.getFirstName());
emailService.sendTemplateEmail(customer.getEmailAddress(), getForgotPasswordEmailInfo(), vars);
}
return response;
}
}
At last i have added following code in Core'applicationContext.xml
Code: Select all
<bean id="org.broadleafcommerce.profile.core.service.CustomerService" class="com.mycompany.profile.forgotpassword.ForgotpasswordNotification" scope="prototype"></bean>
and following code in core persistent.xml
Code: Select all
<class>com.mycompany.profile.forgotpassword.ForgotpasswordNotification</class>
i have written following code in resetPasswordemail.html email template
Code: Select all
<span>Username:</span><span th:text="${Username}"></span>
but still it is calling base function not overridden function.
Please Help???