Search in sources :

Example 1 with PasswordReset

use of org.broadleafcommerce.common.security.util.PasswordReset in project BroadleafCommerce by BroadleafCommerce.

the class CustomerPasswordCustomPersistenceHandler method update.

@Override
public Entity update(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException {
    Entity entity = persistencePackage.getEntity();
    Customer customer = customerService.readCustomerByUsername(entity.findProperty("username").getValue());
    if (StringUtils.isEmpty(customer.getEmailAddress())) {
        throw new ServiceException("Unable to update password because an email address is not available for this customer. An email address is required to send the customer the new system generated password.");
    }
    PasswordReset passwordReset = new PasswordReset();
    passwordReset.setUsername(entity.findProperty("username").getValue());
    passwordReset.setPasswordChangeRequired(false);
    passwordReset.setEmail(customer.getEmailAddress());
    passwordReset.setPasswordLength(22);
    passwordReset.setSendResetEmailReliableAsync(false);
    customer = customerService.resetPassword(passwordReset);
    return entity;
}
Also used : Entity(org.broadleafcommerce.openadmin.dto.Entity) ServiceException(org.broadleafcommerce.common.exception.ServiceException) Customer(org.broadleafcommerce.profile.core.domain.Customer) PasswordReset(org.broadleafcommerce.common.security.util.PasswordReset)

Aggregations

ServiceException (org.broadleafcommerce.common.exception.ServiceException)1 PasswordReset (org.broadleafcommerce.common.security.util.PasswordReset)1 Entity (org.broadleafcommerce.openadmin.dto.Entity)1 Customer (org.broadleafcommerce.profile.core.domain.Customer)1