this.setUserLockReason(null);
this.setUserMustChangePassword(null);
this.setUserName(null);
+ this.setUserPassword(null);
+ this.setUserPasswordRepeat(null);
+ this.setUserProfileMode(null);
+
+ }
+
+ /**
+ * Creates a new user instance from all currently saved data from this bean
+ * <p>
+ * @return New user instance
+ */
+ private User createUserInstance () {
+ // Init variable for password and contact
+ final String password;
+ final Contact userContact;
+
+ // Is a contact instance in helper set?
+ if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) {
+ // Empty password entered, then generate one
+ password = UserLoginUtils.createRandomPassword(FinancialsUserWebRequestController.MINIMUM_PASSWORD_LENGTH);
+ } else if (!this.isSamePasswordEntered()) {
+ // Both passwords don't match
+ throw new FacesException(new UserPasswordRepeatMismatchException());
+ } else {
+ // Both match, so get it from this bean
+ password = this.getUserPassword();
+ }
+
+ // Is contact instance given? Else create one
+ if (this.getContact() instanceof Contact) {
+ // Then use it for contact linking
+ userContact = this.getContact();
+ } else {
+ // Create contact instance
+ userContact = this.contactController.createContactInstance();
+ }
+
+ // Create new instance
+ final User newUser = new LoginUser(
+ this.getUserName(),
+ this.getUserProfileMode(),
+ this.getUserMustChangePassword(),
+ UserLoginUtils.encryptPassword(password),
+ UserAccountStatus.CONFIRMED,
+ userContact
+ );
+
+ // Get locale from view-root
+ final Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
+
+ // Copy user locale
+ newUser.setUserLocale(locale);
+
+ // Return it
+ return newUser;
}
/**