]> git.mxchange.org Git - jjobs-war.git/blobdiff - src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java
Please cherry-pick:
[jjobs-war.git] / src / java / org / mxchange / jjobs / beans / user / JobsAdminUserWebRequestBean.java
index 2e75075673570ef6b8c4e9a407690fce921f07dc..5c4486e512229f54297913b699bbe6aa3bf56cce 100644 (file)
@@ -257,26 +257,31 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm
                        return;
                }
 
+               // Init variable
+               final User updatedUser;
+
                try {
                        // Now, that all is set, call EJB
                        if (this.getContact() instanceof Contact) {
                                // Link contact with this user
-                               final User updatedUser = this.adminUserBean.linkUser(newUser);
-
-                               // Fire event
-                               this.userLinkedEvent.fire(new AdminLinkedUserEvent(updatedUser));
+                               updatedUser = this.adminUserBean.linkUser(newUser);
                        } else {
                                // Add new user
-                               final User updatedUser = this.adminUserBean.addUser(newUser);
-
-                               // Fire event
-                               this.addedUserEvent.fire(new AdminAddedUserEvent(updatedUser));
+                               updatedUser = this.adminUserBean.addUser(newUser);
                        }
                } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
                        // Throw again
                        throw new FacesException(ex);
                }
 
+               // Now, that all is set, call EJB
+               if (this.getContact() instanceof Contact) {
+                       // Fire event
+                       this.userLinkedEvent.fire(new AdminLinkedUserEvent(updatedUser));
+               } else {
+                       // Fire event
+                       this.addedUserEvent.fire(new AdminAddedUserEvent(updatedUser));
+               }
                // Clear helper
                this.setContact(null);
 
@@ -760,7 +765,14 @@ public class JobsAdminUserWebRequestBean extends BaseJobsBean implements JobsAdm
                }
 
                // Create new instance
-               final User newUser = new LoginUser(this.getUserName(), this.getUserProfileMode(), this.getUserMustChangePassword(), UserLoginUtils.encryptPassword(password), UserAccountStatus.CONFIRMED, userContact);
+               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();