Corrección de error en el alta de usuarios y formato de la pantalla de

login de usuarios.
This commit is contained in:
Marcos Garcia Nuñez
2019-12-08 10:57:39 +01:00
parent 3a7a27e609
commit 1dff77f32a
13 changed files with 153 additions and 71 deletions

View File

@@ -45,8 +45,11 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email) {
PatientTO paTO = null;
if (id == null)
id = 1;
PatientJPA ms = new PatientJPA(id, nif, name, surname, HashUtils.hashMD5(password), email);
PatientJPA ms = new PatientJPA(nif, name, surname, HashUtils.hashMD5(password), email);
entman.persist(ms);
paTO = new PatientTO(ms.getId(), ms.getNif(), ms.getName(), ms.getSurname(), ms.getPassword(), ms.getEmail());
@@ -60,8 +63,9 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
// TODO: Lanzar error si no se encuentra la especialidad.
if (ms != null) {
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(id, nif, name, surname, HashUtils.hashMD5(password), email);
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(nif, name, surname, HashUtils.hashMD5(password), email, ms);
entman.persist(sd);
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail());
}
@@ -76,9 +80,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
// TODO: Lanzar error si no encontramos el cap!!!!!
if (phcC != null) {
FamilyDoctorJPA fd = new FamilyDoctorJPA(id, nif, name, surname, HashUtils.hashMD5(password), email);
fd.setPrimaryHealthCareCenter(phcC);
FamilyDoctorJPA fd = new FamilyDoctorJPA(nif, name, surname, HashUtils.hashMD5(password), email, phcC);
entman.persist(fd);
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail());

View File

@@ -4,9 +4,9 @@ import java.util.Collection;
import javax.ejb.Remote;
import TO.LoggedUserTO;
import TO.MedicalSpecialtyTO;
import TO.PrimaryHealthCareCenterTO;
import TO.LoggedUserTO;
/**
*

View File

@@ -42,13 +42,13 @@ public class FamilyDoctorJPA implements Serializable {
super();
}
public FamilyDoctorJPA(int id, String nif, String name, String surname, String password, String email) {
this.id = id;
public FamilyDoctorJPA(String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterJPA phc) {
this.nif = nif;
this.name = name;
this.surname = surname;
this.password = password;
this.email = email;
this.primaryHealthCareCenter = phc;
}
@Id

View File

@@ -40,8 +40,7 @@ public class PatientJPA implements Serializable {
super();
}
public PatientJPA(int id, String nif, String name, String surname, String password, String email) {
this.id = id;
public PatientJPA(String nif, String name, String surname, String password, String email) {
this.nif = nif;
this.name = name;
this.surname = surname;

View File

@@ -37,13 +37,13 @@ public class SpecialistDoctorJPA implements Serializable {
super();
}
public SpecialistDoctorJPA(Integer id, String nif, String name, String surname, String password, String email) {
this.id = id;
public SpecialistDoctorJPA(String nif, String name, String surname, String password, String email, MedicalSpecialtyJPA ms) {
this.nif = nif;
this.name = name;
this.surname = surname;
this.password = password;
this.email = email;
this.medicalSpecialty = ms;
}
@Id

View File

@@ -26,8 +26,7 @@ public class AuthorizationFilter implements Filter {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
try {
HttpServletRequest reqt = (HttpServletRequest) request;
@@ -35,8 +34,9 @@ public class AuthorizationFilter implements Filter {
HttpSession ses = reqt.getSession(false);
String reqURI = reqt.getRequestURI();
if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/RegisterUser.xhtml") >= 0 || (ses != null && ses.getAttribute("username") != null)
|| reqURI.indexOf("/public/") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 || reqURI.contains("javax.faces.resource"))
if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/RegisterUser.xhtml") >= 0 || reqURI.indexOf("/RegisterUserResult.xhtml") >= 0
|| (ses != null && ses.getAttribute("username") != null) || reqURI.indexOf("/public/") >= 0 || reqURI.indexOf("/home.xhtml") >= 0
|| reqURI.contains("javax.faces.resource"))
chain.doFilter(request, response);
else
resp.sendRedirect(reqt.getContextPath() + "/login.xhtml");

View File

@@ -184,15 +184,15 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
this.nif = nif;
}
public Integer getId() {
public int getId() {
return id;
}
public void setId(Integer id) {
public void setId(int id) {
this.id = id;
}
public void addNewUser() {
public String addNewUser() {
int error = 0;
if (this.isFamilyDoctor() && this.primaryHealthCareCenter == null) {
@@ -213,28 +213,33 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
switch (UserType.valueOf(this.userType)) {
case PATIENT:
PatientTO pat = this.remoteManager.registerPatient(id, nif, name, surname, password, email);
this.id = pat.getId();
break;
case FAMILY_DOCTOR:
FamilyDoctorTO fd = this.remoteManager.registerFamilyDoctor1(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
this.id = fd.getId();
break;
case SPECIALIST_DOCTOR:
SpecialistDoctorTO sd = this.remoteManager.registerSpecialistDoctor(id, nif, name, surname, password, email, this.medicalSpecialty);
this.id = sd.getId();
break;
case ADMINISTRADOR:
throw new NotSupportedException("No se soporta el registro directo de administradores.");
}
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Alta realizada",
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Registro realizado",
"El usuario " + name + " " + surname + " se ha registrado correctamente. Por favor, comprueba su correo electrónico para verificar su cuenta.");
return "RegisterUserResult";
} catch (Exception e) {
this.manageException(e);
}
}
// FacesContext.getCurrentInstance().addMessage(null, msg);
return "";
}
public String getPasswordRepeat() {