import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
+import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
-import javax.faces.view.facelets.FaceletException;
import javax.inject.Inject;
import javax.inject.Named;
import org.mxchange.jcoreee.utils.FacesUtils;
throw new IllegalStateException("User is not logged-in"); //NOI18N
} else if (!this.isRequiredChangePasswordSet()) {
// Not all required fields are set
- throw new FaceletException("Not all required fields are set."); //NOI18N
+ throw new FacesException("Not all required fields are set."); //NOI18N
} else if (!this.userLoginController.ifCurrentPasswordMatches()) {
// Password not matching
- throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
+ throw new FacesException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
} else if (!this.featureController.isFeatureEnabled("change_user_password")) { //NOI18N
// Editing is not allowed
throw new IllegalStateException("User tried to change password."); //NOI18N
// Set it in user
user.setUserEncryptedPassword(encryptedPassword);
+ // Init variable
+ final PasswordHistory passwordHistory;
+
try {
// Get base URL
final String baseUrl = FacesUtils.generateBaseUrl();
// All is set, then update password
- PasswordHistory passwordHistory = this.userBean.updateUserPassword(user, baseUrl);
-
- // Fire event
- this.userUpdatedPasswordEvent.fire(new UpdatedUserPasswordEvent(passwordHistory, this.getUserPassword()));
+ passwordHistory = this.userBean.updateUserPassword(user, baseUrl);
} catch (final UserNotFoundException | UserStatusUnconfirmedException | UserStatusLockedException ex) {
// Clear bean
this.clear();
// Throw again
- throw new FaceletException(ex);
+ throw new FacesException(ex);
}
+ // Fire event
+ this.userUpdatedPasswordEvent.fire(new UpdatedUserPasswordEvent(passwordHistory, this.getUserPassword()));
+
// Clear bean
this.clear();