Skip to content

Commit

Permalink
theRapist
Browse files Browse the repository at this point in the history
  • Loading branch information
panuozzo77 committed Jan 6, 2024
1 parent 4f6473e commit d3cfc51
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
13 changes: 2 additions & 11 deletions src/main/java/controller/Login.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,13 @@ private String setSessionAttributes(int id, HttpServletRequest request){

session.setAttribute("type", "patient");
session.setAttribute("therapist", user.getIdTherapist());
return "JSP/homePatient.jsp";
return "JSP/homepagepatient.jsp";
}
else {
setPatientsInfo(session);
session.setAttribute("type", "therapist");
session.setAttribute("surname", personalInfo.getLastname());
return "JSP/homeTherapist.jsp";
}
}
private void setPatientsInfo(HttpSession session){

UserRegistry registry = new UserRegistry();

PersonalInfo infoLogged = registry.getPersonalInfo(((Integer) session.getAttribute("id")));

session.setAttribute("NameSurnameLogged", infoLogged != null ? infoLogged.getFirstname() + " " + infoLogged.getLastname() : null);

}
}

2 changes: 1 addition & 1 deletion src/main/webapp/JSP/homeTherapist.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<img class="img" src="../images/homeTherapist/doctor.png" />
<img class="logovettoriale" src="../images/homeTherapist/logovettoriale-1.png" />
<img class="line" src="../images/homeTherapist/line-9.svg" />
<div class="text-wrapper-3">Dr.</br> <%=session.getAttribute("NameSurnameLogged")%></div>
<div class="text-wrapper-3">Dr.</br> <%=(String) session.getAttribute("name") + " " + (String)session.getAttribute("surname")%></div>
<img class="ellipse-2" src="../images/homeTherapist/ellipse-94.svg" />
</div>
<div class="material-symbols-wrapper">
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/JSP/view_patient.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<img class="img" src="../images/homeTherapist/doctor.png" />
<img class="logovettoriale" src="../images/homeTherapist/logovettoriale-1.png" />
<img class="line" src="../images/homeTherapist/line-9.svg" />
<div class="text-wrapper-3">Dr.</br> <%=session.getAttribute("NameSurnameLogged")%></div>
<div class="text-wrapper-3">Dr.</br> <%=(String) session.getAttribute("name") + " " + (String)session.getAttribute("surname")%> </div>
<img class="ellipse-2" src="../images/homeTherapist/ellipse-94.svg" />
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/controller/LoginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ void testDoPostWithValidCredentials() throws Exception {
verify(mockSession).setAttribute("type", "patient");

// Verify redirection
verify(response).sendRedirect("JSP/welcome.jsp");
verify(response).sendRedirect("JSP/homepagepatient.jsp");
}

//ACCESSO LOGOPEDISTA CORRETTO
@Test
void testDoPostWithValidCredentials2() throws Exception {
// Setup test data
Expand All @@ -75,7 +76,7 @@ void testDoPostWithValidCredentials2() throws Exception {
verify(mockSession).setAttribute("type", "therapist");

// Verify redirection
verify(response).sendRedirect("JSP/welcome.jsp");
verify(response).sendRedirect("JSP/homeTherapist.jsp");
}

@Test
Expand Down

0 comments on commit d3cfc51

Please sign in to comment.