From: Roland Häder Date: Sun, 9 Jul 2017 10:46:02 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d0f148d67dd7007274f7185bb296512c3153dde0;p=pizzaservice-ejb.git Please cherry-pick: - renamed updatedUser -> managedUser, which is more accurate - always set values in managed instances to have the JPA noticed it Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java index 4049040..c1d02c6 100644 --- a/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/PizzaUserSessionBean.java @@ -169,22 +169,22 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS throw new IllegalArgumentException("baseUrl is empty"); //NOI18N } - // Update user status and remove confirmation key - user.setUserAccountStatus(UserAccountStatus.CONFIRMED); - user.setUserConfirmKey(null); - user.setUserUpdated(new GregorianCalendar()); - // Update user account - User updatedUser = this.updateUserData(user); + User managedUser = this.updateUserData(user); + + // Update user status and remove confirmation key + managedUser.setUserAccountStatus(UserAccountStatus.CONFIRMED); + managedUser.setUserConfirmKey(null); + managedUser.setUserUpdated(new GregorianCalendar()); // Send out email - this.sendEmail("User account confirmed", "user_account_confirmed", updatedUser, baseUrl, null); //NOI18N + this.sendEmail("User account confirmed", "user_account_confirmed", managedUser, baseUrl, null); //NOI18N // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N // Return updated instance - return updatedUser; + return managedUser; } @Override @@ -634,16 +634,19 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS } // Call other method - User updatedUser = this.updateUserData(user); + User managedUser = this.updateUserData(user); + + // Update user account + managedUser.setUserUpdated(new GregorianCalendar()); // Create history entry - PasswordHistory entry = new UserPasswordHistory(updatedUser.getUserEncryptedPassword(), updatedUser); + PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), managedUser); // Set created timestamp entry.setUserPasswordHistoryCreated(new GregorianCalendar()); // Merge user to make sure it is not re-persisted - User mergedUser = this.getEntityManager().merge(updatedUser); + User mergedUser = this.getEntityManager().merge(managedUser); entry.setUserPasswordHistoryUser(mergedUser); // Persist it @@ -653,7 +656,7 @@ public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserS this.getEntityManager().flush(); // Send email to user - this.sendEmail("User password change", "user_password_change", updatedUser, baseUrl, null); //NOI18N + this.sendEmail("User password change", "user_password_change", managedUser, baseUrl, null); //NOI18N // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: entry.userPasswordHistoryId={1} - EXIT!", this.getClass().getSimpleName(), entry.getUserPasswordHistoryId())); //NOI18N diff --git a/src/java/org/mxchange/jusercore/model/user/resendlink/PizzaResendLinkSessionBean.java b/src/java/org/mxchange/jusercore/model/user/resendlink/PizzaResendLinkSessionBean.java index d2290d4..6cdf837 100644 --- a/src/java/org/mxchange/jusercore/model/user/resendlink/PizzaResendLinkSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/resendlink/PizzaResendLinkSessionBean.java @@ -98,6 +98,9 @@ public class PizzaResendLinkSessionBean extends BasePizzaDatabaseBean implements // Get new registration key String confirmationKey = this.registerBean.generateConfirmationKey(user); + // Debug message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.resendConfirmationLink: confirmationKey={1}", this.getClass().getSimpleName(), confirmationKey)); //NOI18N + // Get managed instance User managedUser = this.getEntityManager().find(LoginUser.class, user.getUserId()); @@ -106,7 +109,7 @@ public class PizzaResendLinkSessionBean extends BasePizzaDatabaseBean implements // Send email // @TODO: Internationlize the subject line somehow - this.sendEmail("Resend user confirmation link", "user_resend_confirmation_link", user, baseUrl, null); //NOI18N + this.sendEmail("Resend user confirmation link", "user_resend_confirmation_link", managedUser, baseUrl, null); //NOI18N // Log trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.resendConfirmationLink: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N