String pass = f.getString(Params.USER_ACCOUNT.VALIDATE.PARAMS.PASSWORD);
String passConfirm = f.getString(Params.USER_ACCOUNT.VALIDATE.PARAMS.CONFIRM_PASSWORD);
boolean emailChanged = false;
if (ActionsHelper.noneEmpty(new String[] {login,email,fName,lName,country})) {
UserImpl u = (UserImpl)ServiceFactory.getUserService().getUser(login);
if (!StringUtils.isEmpty(pass) && !StringUtils.isEmpty(passConfirm)) {
// both password are given, we check equality
if (pass.equals(passConfirm)) {
LOGGER.info("user " + u.getLogin() + " is changing is password");
u.setPassword(pass);
} else {
addWOJMessages(request, RessourceBundleApplicationMessage.error("registration.user-form.error.password.not.identical", null));
LOGGER.debug("passwords are not identiqual [" + pass + ":" + passConfirm +"]");
return "user.account.showForm";
}
} else {
// at least one of password is empty
if (!ActionsHelper.allEmpty(new String[] {pass, passConfirm})){
addWOJMessages(request, RessourceBundleApplicationMessage.error("registration.user-form.error.password.missing", null));
LOGGER.debug("only one password provided [" + pass + ":" + passConfirm +"]");
return "user.account.showForm";
}
// both passwords are empty
}
if (!email.equals(u.getEmail())) {
if (ServiceFactory.getUserService().getUserByEmail(email) != null) {
// The user already exists
addWOJMessages(request, RessourceBundleApplicationMessage.error("registration.user-form.error.email.already.exists", null));
LOGGER.debug("duplicate email found when validating user account page, " + email + " is already used");
return "user.account.showForm";
}
// Email has changed
u.setEmail(email);
u.setMailVerified(false);
emailChanged = true;
addWOJMessages(request, RessourceBundleApplicationMessage.warning("woj.user.account.email.changed", null));
}
u.setFirstName(fName);
u.setLastName(lName);
u.setAdress(adress);
u.setCity(city);
u.setPostalCode(postalCode);
u.setCountry(country);
u.setCompany(cName);
u.setCompanyHomepage(cHomepage);
ServiceFactory.getUserService().update(u);
addWOJMessages(request, RessourceBundleApplicationMessage.info("woj.user.account.updated", null));
if (emailChanged) {