Nueva propiedad para guardar el displayName del usuario logeado.
This commit is contained in:
@@ -18,18 +18,19 @@ public class LoggedUserTO implements Serializable {
|
|||||||
private String id;
|
private String id;
|
||||||
private String password;
|
private String password;
|
||||||
private String name;
|
private String name;
|
||||||
|
private String displayName;
|
||||||
private UserType userType;
|
private UserType userType;
|
||||||
|
|
||||||
public LoggedUserTO() {
|
public LoggedUserTO() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoggedUserTO(String usrId, String usrName, String usrPwd, UserType usrType) {
|
public LoggedUserTO(String usrId, String usrName, String usrPwd, UserType usrType, String dispName) {
|
||||||
id = usrId;
|
id = usrId;
|
||||||
name = usrName;
|
name = usrName;
|
||||||
password = usrPwd;
|
password = usrPwd;
|
||||||
userType = usrType;
|
userType = usrType;
|
||||||
|
displayName = dispName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@@ -64,4 +65,12 @@ public class LoggedUserTO implements Serializable {
|
|||||||
this.userType = value;
|
this.userType = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplayName(String displayName) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,29 +33,23 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
|||||||
CommonFacadeLocal commonServices;
|
CommonFacadeLocal commonServices;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Si la autenticación no es correcgta devuelve null, sino devuelve un POJO con
|
* Si la autenticación no es correcgta devuelve null, sino devuelve un POJO con datos del usuario logeado.
|
||||||
* datos del usuario logeado.
|
|
||||||
*
|
*
|
||||||
* La autenticación se realiza en 2 pasos:
|
* La autenticación se realiza en 2 pasos:
|
||||||
*
|
*
|
||||||
* Paso 1. Se intenta localizar un registro de usuario, por orden:
|
* Paso 1. Se intenta localizar un registro de usuario, por orden:
|
||||||
*
|
*
|
||||||
* a. Primero Paciente, si el identificador comienza por los caracteres
|
* a. Primero Paciente, si el identificador comienza por los caracteres correctos.
|
||||||
* correctos.
|
|
||||||
*
|
*
|
||||||
* b.Después médico de familia, si el identificador es de profesional
|
* b.Después médico de familia, si el identificador es de profesional
|
||||||
*
|
*
|
||||||
* c. Si no lo localizamos buscamos el identificador en la tabla de médicos
|
* c. Si no lo localizamos buscamos el identificador en la tabla de médicos especialistas (el identificador es de profesional)
|
||||||
* especialistas (el identificador es de profesional)
|
|
||||||
*
|
*
|
||||||
* d. Si no hemos localizado aún al usuario, lo buscamos en la tabla de
|
* d. Si no hemos localizado aún al usuario, lo buscamos en la tabla de administradores, aún cuando el identificador comience por cualquier carácter (podría ser una dirección
|
||||||
* administradores, aún cuando el identificador comience por cualquier carácter
|
* de email que comienza por caracteres del identificaodr de paciente o profesional)
|
||||||
* (podría ser una dirección de email que comienza por caracteres del
|
|
||||||
* identificaodr de paciente o profesional)
|
|
||||||
*
|
*
|
||||||
* Paso 2. Si hemos localizado un registro de usuario, verificamos si el
|
* Paso 2. Si hemos localizado un registro de usuario, verificamos si el password recibido coincide con el de la base de datos, en tal caso la autenticación se compelta y es
|
||||||
* password recibido coincide con el de la base de datos, en tal caso la
|
* correcta.
|
||||||
* autenticación se compelta y es correcta.
|
|
||||||
*/
|
*/
|
||||||
public LoggedUserTO login(String userCode, String pwd) {
|
public LoggedUserTO login(String userCode, String pwd) {
|
||||||
LoggedUserTO usr = null;
|
LoggedUserTO usr = null;
|
||||||
@@ -65,7 +59,7 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
|||||||
// login.
|
// login.
|
||||||
PatientTO pat = this.commonServices.findPatientByCode(userCode);
|
PatientTO pat = this.commonServices.findPatientByCode(userCode);
|
||||||
if (pat != null) {
|
if (pat != null) {
|
||||||
usr = new LoggedUserTO(String.valueOf(pat.getId()), pat.getName(), pat.getPassword(), UserType.PATIENT);
|
usr = new LoggedUserTO(String.valueOf(pat.getId()), pat.getName(), pat.getPassword(), UserType.PATIENT, pat.getDisplayName());
|
||||||
}
|
}
|
||||||
} else if (userCode.startsWith(Constants.PROFESSIONAL_NUMBER_PREFIX)) {
|
} else if (userCode.startsWith(Constants.PROFESSIONAL_NUMBER_PREFIX)) {
|
||||||
// Si el identificador de usuario es de tipo profesional, intentamos realizar el
|
// Si el identificador de usuario es de tipo profesional, intentamos realizar el
|
||||||
@@ -73,13 +67,13 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
|||||||
FamilyDoctorTO fd = this.commonServices.findFamilyDoctorByCode(userCode);
|
FamilyDoctorTO fd = this.commonServices.findFamilyDoctorByCode(userCode);
|
||||||
|
|
||||||
if (fd != null) {
|
if (fd != null) {
|
||||||
usr = new LoggedUserTO(String.valueOf(fd.getId()), fd.getName(), fd.getPassword(), UserType.FAMILY_DOCTOR);
|
usr = new LoggedUserTO(String.valueOf(fd.getId()), fd.getName(), fd.getPassword(), UserType.FAMILY_DOCTOR, fd.getDisplayName());
|
||||||
} else {
|
} else {
|
||||||
// No era un código de médico de familia, intenamos logearlo como especialista
|
// No era un código de médico de familia, intenamos logearlo como especialista
|
||||||
SpecialistDoctorTO sd = this.commonServices.findSpecialistDoctorByCode(userCode);
|
SpecialistDoctorTO sd = this.commonServices.findSpecialistDoctorByCode(userCode);
|
||||||
|
|
||||||
if (sd != null) {
|
if (sd != null) {
|
||||||
usr = new LoggedUserTO(String.valueOf(sd.getId()), sd.getName(), sd.getPassword(), UserType.SPECIALIST_DOCTOR);
|
usr = new LoggedUserTO(String.valueOf(sd.getId()), sd.getName(), sd.getPassword(), UserType.SPECIALIST_DOCTOR, sd.getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,7 +87,7 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
|||||||
AdministratorJPA adm = entman.find(AdministratorJPA.class, userCode);
|
AdministratorJPA adm = entman.find(AdministratorJPA.class, userCode);
|
||||||
|
|
||||||
if (adm != null) {
|
if (adm != null) {
|
||||||
usr = new LoggedUserTO(adm.getEmail(), adm.getEmail(), adm.getPassword(), UserType.ADMINISTRATOR);
|
usr = new LoggedUserTO(adm.getEmail(), adm.getEmail(), adm.getPassword(), UserType.ADMINISTRATOR, adm.getEmail());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,16 @@ public class SessionUtils {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUserDisplayName() {
|
||||||
|
HttpSession session = getSession();
|
||||||
|
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USER) != null) {
|
||||||
|
LoggedUserTO usr = LoggedUserTO.class.cast(session.getAttribute(SessionUtils.SESSION_VAR_USER));
|
||||||
|
|
||||||
|
return usr.getDisplayName();
|
||||||
|
} else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
public static UserType getUserType() {
|
public static UserType getUserType() {
|
||||||
return getUserType(getSession());
|
return getUserType(getSession());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,19 +300,19 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
|||||||
case PATIENT:
|
case PATIENT:
|
||||||
PatientTO pat = this.getRemoteManagerProfile().updatePatientData(id, nif, name, surname, password, email);
|
PatientTO pat = this.getRemoteManagerProfile().updatePatientData(id, nif, name, surname, password, email);
|
||||||
this.setPatientData(pat);
|
this.setPatientData(pat);
|
||||||
usr = new LoggedUserTO(pat.getId().toString(), pat.getName(), pat.getPassword(), this.userType);
|
usr = new LoggedUserTO(pat.getId().toString(), pat.getName(), pat.getPassword(), this.userType, pat.getDisplayName());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FAMILY_DOCTOR:
|
case FAMILY_DOCTOR:
|
||||||
FamilyDoctorTO fd = this.getRemoteManagerProfile().updateFamilyDoctorData(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
|
FamilyDoctorTO fd = this.getRemoteManagerProfile().updateFamilyDoctorData(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
|
||||||
this.setFamilyDoctorData(fd);
|
this.setFamilyDoctorData(fd);
|
||||||
usr = new LoggedUserTO(fd.getId().toString(), fd.getName(), fd.getPassword(), this.userType);
|
usr = new LoggedUserTO(fd.getId().toString(), fd.getName(), fd.getPassword(), this.userType, fd.getDisplayName());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SPECIALIST_DOCTOR:
|
case SPECIALIST_DOCTOR:
|
||||||
SpecialistDoctorTO sd = this.getRemoteManagerProfile().updateSpecialistDoctorData(id, nif, name, surname, password, email, this.medicalSpecialty);
|
SpecialistDoctorTO sd = this.getRemoteManagerProfile().updateSpecialistDoctorData(id, nif, name, surname, password, email, this.medicalSpecialty);
|
||||||
this.setSpecialistDoctorData(sd);
|
this.setSpecialistDoctorData(sd);
|
||||||
usr = new LoggedUserTO(sd.getId().toString(), sd.getName(), sd.getPassword(), this.userType);
|
usr = new LoggedUserTO(sd.getId().toString(), sd.getName(), sd.getPassword(), this.userType, sd.getDisplayName());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ADMINISTRATOR:
|
case ADMINISTRATOR:
|
||||||
|
|||||||
Reference in New Issue
Block a user