use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method addUser.
/**
* permet de créer un nouvel utilisateur avec le role et dans le groupe en
* cours
*
* @param idGroup
* @return
*/
public boolean addUser(String idGroup) {
UserHelper2 userHelper = new UserHelper2();
if (pwdAdded1 == null || pwdAdded1.equals("") || pwdAdded2 == null || pwdAdded2.equals("") || pseudoAdded == null || pseudoAdded.equals("") || mailAdded.equals("") || mailAdded == null) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error2")));
return false;
}
if (!pwdAdded1.equals(pwdAdded2)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error3")));
return false;
}
if (userHelper.isPseudoExist(connect.getPoolConnexion(), pseudoAdded)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error5")));
return false;
}
if (userHelper.isMailExist(connect.getPoolConnexion(), mailAdded)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.info7")));
return false;
}
int idUser;
int idGroupTemp = -1;
boolean isSuperAdmin = false;
if (idGroup != null) {
if (!idGroup.isEmpty()) {
idGroupTemp = Integer.parseInt(idGroup);
} else
idGroupTemp = -1;
}
if (roleAdded == 1)
isSuperAdmin = true;
if (!userHelper.addUser(connect.getPoolConnexion(), pseudoAdded, mailAdded, MD5Password.getEncodedPassword(pwdAdded1), isSuperAdmin, alertmail)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return false;
}
idUser = userHelper.getIdUser(connect.getPoolConnexion(), pseudoAdded, MD5Password.getEncodedPassword(pwdAdded1));
if (idUser == -1) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return false;
}
// / si idGroupTemp = -1 : création d'utilisateur sans groupe
if (!isSuperAdmin && idGroupTemp != -1) {
// on ajoute l'utilisateur au groupe séléctionné par l'utilisateur
if (!userHelper.addUserRoleOnGroup(connect.getPoolConnexion(), idUser, roleAdded, idGroupTemp)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("error.BDD")));
return false;
}
}
mailAdded = "";
pwdAdded1 = "";
pwdAdded2 = "";
pseudoAdded = "";
roleAdded = -1;
groupAdded = "";
listUsersByGroup();
if (isSuperAdmin)
listSuperAdmin();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info3")));
return true;
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method listAllGroupUser.
private void listAllGroupUser() {
UserHelper2 userHelper = new UserHelper2();
listeAllGroupUser = userHelper.getAllGroupUser(connect.getPoolConnexion(), connect.getWorkLanguage());
// les users sans groupe en ignorant les superAdmin
ArrayList<NodeUserGroupUser> nodeUserGroupUser_wtihoutGroup = userHelper.getAllGroupUserWithoutGroup(connect.getPoolConnexion(), connect.getWorkLanguage());
if (nodeUserGroupUser_wtihoutGroup != null)
if (!nodeUserGroupUser_wtihoutGroup.isEmpty())
listeAllGroupUser.addAll(nodeUserGroupUser_wtihoutGroup);
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method initPassword.
public void initPassword() {
if (password5 == null) {
return;
}
UserHelper2 userHelper2 = new UserHelper2();
if (!userHelper2.updatePwd(connect.getPoolConnexion(), userEdit.getIdUser(), MD5Password.getEncodedPassword(password5))) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("BDD" + " :", "Error"));
}
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info1")));
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method updatePassword.
/**
* Permet de modifier le mot de passe de l'utilisateur
*/
public void updatePassword() {
if (pwdAdded1 == null || pwdAdded1.equals("") || pwdAdded2 == null || pwdAdded2.equals("") || pwdAdded3 == null || pwdAdded3.equals("")) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error2")));
} else if (!pwdAdded2.equals(pwdAdded3)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error3")));
} else if (!new UserHelper2().isUserExist(connect.getPoolConnexion(), user.getName(), MD5Password.getEncodedPassword(pwdAdded1))) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("user.error4")));
} else {
new UserHelper2().updatePwd(connect.getPoolConnexion(), user.getIdUser(), MD5Password.getEncodedPassword(pwdAdded2));
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("user.info1")));
}
pwdAdded1 = "";
pwdAdded2 = "";
pwdAdded3 = "";
}
use of mom.trd.opentheso.bdd.helper.UserHelper2 in project opentheso by miledrousset.
the class CurrentUser2 method getSelectedGroupName.
public String getSelectedGroupName() {
UserHelper2 userHelper = new UserHelper2();
if (selectedGroup != null)
if (!selectedGroup.isEmpty())
selectedGroupName = userHelper.getGroupName(connect.getPoolConnexion(), Integer.parseInt(selectedGroup));
else
selectedGroupName = selectedGroup;
return selectedGroupName;
}
Aggregations