fix issue with updateprofile notice email sending old values instead of new values

This commit is contained in:
jrivard@gmail.com 2019-04-16 00:35:00 -06:00
parent 0947a44e5a
commit 149985a9f8

View file

@ -45,6 +45,7 @@ import password.pwm.http.PwmRequestAttribute;
import password.pwm.http.bean.UpdateProfileBean;
import password.pwm.ldap.LdapOperationsHelper;
import password.pwm.ldap.UserInfo;
import password.pwm.ldap.UserInfoFactory;
import password.pwm.svc.stats.Statistic;
import password.pwm.svc.token.TokenType;
import password.pwm.svc.token.TokenUtil;
@ -368,28 +369,47 @@ public class UpdateProfileUtil
LdapOperationsHelper.writeFormValuesToLdap( theUser, formMap, macroMachine, false );
final UserIdentity userIdentity = userInfo.getUserIdentity();
postUpdateActionsAndEmail( pwmApplication, sessionLabel, locale, userInfo.getUserIdentity(), updateProfileProfile );
// success, so forward to success page
pwmApplication.getStatisticsManager().incrementValue( Statistic.UPDATE_ATTRIBUTES );
}
private static void postUpdateActionsAndEmail(
final PwmApplication pwmApplication,
final SessionLabel sessionLabel,
final Locale locale,
final UserIdentity userIdentity,
final UpdateProfileProfile updateProfileProfile
)
throws PwmUnrecoverableException, ChaiUnavailableException, PwmOperationalException
{
// obtain new macro machine (with a new UserInfo) so old cached values won't be used for next op
final UserInfo reloadedUserInfo = UserInfoFactory.newUserInfo(
pwmApplication,
sessionLabel,
locale,
userIdentity,
pwmApplication.getProxiedChaiUser( userIdentity ).getChaiProvider() );
final MacroMachine reloadedMacroMachine = MacroMachine.forUser( pwmApplication, sessionLabel, reloadedUserInfo, null, null );
{
// execute configured actions
final List<ActionConfiguration> actions = updateProfileProfile.readSettingAsAction( PwmSetting.UPDATE_PROFILE_WRITE_ATTRIBUTES );
if ( actions != null && !actions.isEmpty() )
{
LOGGER.debug( sessionLabel, () -> "executing configured actions to user " + userIdentity );
LOGGER.debug( sessionLabel, () -> "executing configured actions to user " + reloadedUserInfo.getUserIdentity() );
final ActionExecutor actionExecutor = new ActionExecutor.ActionExecutorSettings( pwmApplication, userIdentity )
final ActionExecutor actionExecutor = new ActionExecutor.ActionExecutorSettings( pwmApplication, reloadedUserInfo.getUserIdentity() )
.setExpandPwmMacros( true )
.setMacroMachine( macroMachine )
.setMacroMachine( reloadedMacroMachine )
.createActionExecutor();
actionExecutor.executeActions( actions, sessionLabel );
}
}
sendProfileUpdateEmailNotice( pwmApplication, macroMachine, userInfo, locale, sessionLabel );
// success, so forward to success page
pwmApplication.getStatisticsManager().incrementValue( Statistic.UPDATE_ATTRIBUTES );
sendProfileUpdateEmailNotice( pwmApplication, reloadedMacroMachine, reloadedUserInfo, locale, sessionLabel );
}
static TokenDestinationItem tokenDestinationItemForCurrentValidation(