Beispiel #1
0
  public static void sendPassword(
      ActionRequest actionRequest,
      String fromName,
      String fromAddress,
      String toAddress,
      String subject,
      String body)
      throws Exception {

    HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    Company company = themeDisplay.getCompany();

    if (!company.isSendPassword() && !company.isSendPasswordResetLink()) {
      return;
    }

    ServiceContext serviceContext =
        ServiceContextFactory.getInstance(User.class.getName(), actionRequest);

    UserLocalServiceUtil.sendPassword(
        company.getCompanyId(), toAddress, fromName, fromAddress, subject, body, serviceContext);

    SessionMessages.add(actionRequest, "request_processed", toAddress);
  }