Añadidos permisos (visibilidad) al menú principal para cada tipo de
usuario. Completada página para edición de datos personales.
This commit is contained in:
@@ -4,18 +4,13 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.resource.NotSupportedException;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.primefaces.PrimeFaces;
|
||||
|
||||
@@ -25,7 +20,6 @@ import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.UserType;
|
||||
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.ValidationUtils;
|
||||
|
||||
@@ -46,8 +40,8 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
private String nif;
|
||||
private String name;
|
||||
private String surname;
|
||||
@Size(min = 4, message = "La contraseña debe tener al menos 4 carácteres.")
|
||||
private String password;
|
||||
private String passwordRepeat;
|
||||
private String email;
|
||||
private boolean registered;
|
||||
|
||||
@@ -227,14 +221,6 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public String getPasswordRepeat() {
|
||||
return passwordRepeat;
|
||||
}
|
||||
|
||||
public void setPasswordRepeat(String passwordRepeat) {
|
||||
this.passwordRepeat = passwordRepeat;
|
||||
}
|
||||
|
||||
public String getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import TO.MedicalSpecialtyTO;
|
||||
import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.HashUtils;
|
||||
import common.UserType;
|
||||
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
@@ -49,10 +50,10 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
private String nif;
|
||||
private String name;
|
||||
private String surname;
|
||||
private String currentPassword;
|
||||
private String oldPassword;
|
||||
private String password;
|
||||
private String passwordRepeat;
|
||||
private String email;
|
||||
private boolean registered;
|
||||
|
||||
// private HashMap<String, String> userTypes;
|
||||
private List<UserType> userTypes;
|
||||
@@ -97,6 +98,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.surname = pat.getName();
|
||||
this.nif = pat.getNif();
|
||||
this.email = pat.getEmail();
|
||||
this.currentPassword = pat.getPassword();
|
||||
break;
|
||||
case SPECIALIST_DOCTOR:
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerSystemAdmin().listAllMedicalSpecialities();
|
||||
@@ -106,6 +108,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.surname = sd.getName();
|
||||
this.nif = sd.getNif();
|
||||
this.email = sd.getEmail();
|
||||
this.currentPassword = sd.getPassword();
|
||||
this.medicalSpecialty = sd.getMedicalSpecialty();
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
@@ -116,6 +119,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.surname = fd.getName();
|
||||
this.nif = fd.getNif();
|
||||
this.email = fd.getEmail();
|
||||
this.currentPassword = fd.getPassword();
|
||||
this.primaryHealthCareCenter = fd.getPrimaryHealthCareCenter();
|
||||
break;
|
||||
case ADMINISTRADOR:
|
||||
@@ -227,6 +231,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
|
||||
public void saveData() {
|
||||
int error = 0;
|
||||
boolean changePassword = (this.oldPassword != null && this.oldPassword.equals("") == false) || (this.password != null && this.password.equals("") == false);
|
||||
|
||||
if (this.isFamilyDoctor() && this.primaryHealthCareCenter == null) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Centro de atención primaria no seleccionado", "Por favor, especifique un centro de atención primaria.");
|
||||
@@ -240,6 +245,16 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido.");
|
||||
error++;
|
||||
}
|
||||
if (changePassword == true) {
|
||||
// el usuario queire cambiar el password Comprobamos que el password especificado coincide con el guardado
|
||||
if (this.password == null || this.password.length() < 4) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Nueva contraseña incorrectra", "Su nueva contraseña debe tener al menos 4 caracteres.");
|
||||
error++;
|
||||
} else if (HashUtils.hashMD5(this.oldPassword).equals(this.currentPassword) == false ) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Contraseña actual incorrecta", "Su actual contraseña es incorrecta. Por favor, especifique su contraseña actual.");
|
||||
error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
@@ -260,26 +275,22 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
|
||||
break;
|
||||
case ADMINISTRADOR:
|
||||
throw new NotSupportedException("No se soporta la edición de perfiles de administrador.");
|
||||
throw new NotSupportedException("No se soporta la edición de perfiles de tipo administrador.");
|
||||
}
|
||||
|
||||
this.registered = true;
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Los datos guardados", "Los datos de su perfil se han guardado correctamente en la base de datos.");
|
||||
|
||||
if (changePassword == true) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Contraseña actualizada", "Su contraseña ha sido actualizada correctamente.");
|
||||
this.password = "";
|
||||
this.oldPassword = "";
|
||||
}
|
||||
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Los datos se han guardado", "Los datos de su perfil se han guardado correctamente.");
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getPasswordRepeat() {
|
||||
return passwordRepeat;
|
||||
}
|
||||
|
||||
public void setPasswordRepeat(String passwordRepeat) {
|
||||
this.passwordRepeat = passwordRepeat;
|
||||
}
|
||||
|
||||
public String getUserType() {
|
||||
return userType;
|
||||
}
|
||||
@@ -304,8 +315,12 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.primaryHealthCareCenter = primaryHealthCareCenter;
|
||||
}
|
||||
|
||||
public boolean isRegistered() {
|
||||
return registered;
|
||||
public String getOldPassword() {
|
||||
return oldPassword;
|
||||
}
|
||||
|
||||
public void setOldPassword(String oldPassword) {
|
||||
this.oldPassword = oldPassword;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user