public ActionForward execute(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   User user = LegacySpringUtils.getUserManager().getLoggedInUser();
   String suppliedOldPassword = BeanUtils.getProperty(form, "oldpassword");
   String actualOldPassword = user.getPassword();
   String hashedSuppliedOldPassword = LogonUtils.hashPassword(suppliedOldPassword);
   if (hashedSuppliedOldPassword.equals(actualOldPassword)) {
     user.setPassword(LogonUtils.hashPassword(BeanUtils.getProperty(form, "passwordPwd")));
     user.setFirstlogon(false);
     LegacySpringUtils.getUserManager().save(user);
     AddLog.addLog(
         user.getUsername(),
         AddLog.PASSWORD_CHANGE,
         user.getUsername(),
         "",
         UserUtils.retrieveUsersRealUnitcodeBestGuess(user.getUsername()),
         "");
     return mapping.findForward("success");
   } else {
     request.setAttribute("error", "incorrect current password");
     return mapping.findForward("input");
   }
 }
예제 #2
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    String forward = "";
    ActionUtils.setUpNavLink(mapping.getParameter(), request);
    NewsUtils.putAppropriateNewsForViewingInRequest(request);
    User user = LegacySpringUtils.getUserManager().getLoggedInUser();

    if (user != null) {

      final String role = LegacySpringUtils.getUserManager().getCurrentSpecialtyRole(user);

      // Is user patient or admin?
      if ("patient".equalsIgnoreCase(role)) {
        request.setAttribute("isPatient", true);
      }
      if ((user.getLastlogon() != null)) {
        request.setAttribute("lastLogin", format.format(user.getLastlogon()));
      }
      user.setLastlogon(new Date());

      LegacySpringUtils.getUserManager().save(user);

      if ("patient".equalsIgnoreCase(role)) {

        String nhsno =
            LegacySpringUtils.getUserManager().getUsersRealNhsNoBestGuess(user.getUsername());

        if (nhsno != null && !nhsno.equals("")) {
          LogEntry log =
              LegacySpringUtils.getLogEntryManager()
                  .getLatestLogEntry(nhsno, AddLog.PATIENT_DATA_FOLLOWUP);
          if (log != null) {
            request.setAttribute("lastDataDate", format.format(log.getDate().getTime()));
            // Get the unit from the unitcode
            String unitcode = log.getUnitcode();
            if (unitcode != null) {
              Unit unit = LegacySpringUtils.getUnitManager().get(unitcode);
              if (null == unit) {
                request.setAttribute("lastDataFrom", "Unit with code: " + unitcode);
              } else {
                request.setAttribute("lastDataFrom", unit.getName());
              }
            }
          }
        }
        forward = "patient";
      } else {
        forward = "admin";
      }
    }
    return LogonUtils.logonChecks(mapping, request, forward);
  }
 public ActionForward execute(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   String unitcode = BeanUtils.getProperty(form, "unitcode");
   unitcode = (unitcode == null) ? "" : unitcode;
   String nhsno = BeanUtils.getProperty(form, "nhsno");
   nhsno = (nhsno == null) ? "" : nhsno;
   String name = BeanUtils.getProperty(form, "name");
   name = (name == null) ? "" : name;
   boolean showgps = "true".equals(BeanUtils.getProperty(form, "showgps"));
   DatabaseDAO dao = getDao(request);
   if (!"".equals(unitcode)) {
     HibernateUtil.retrievePersistentObjectAndAddToRequestWithIdParameter(
         request, Unit.class, unitcode, "unit");
   }
   UnitPatientsWithTreatmentDao patientDao =
       new UnitPatientsWithTreatmentDao(unitcode, nhsno, name, showgps);
   List patients = dao.retrieveList(patientDao);
   request.setAttribute("patients", patients);
   return LogonUtils.logonChecks(mapping, request);
 }