@Override
  protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse)
      throws Exception {

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

    Company company = themeDisplay.getCompany();

    if (!company.isStrangers()) {
      throw new PrincipalException.MustBeEnabled(
          company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS);
    }

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {
      if (cmd.equals(Constants.ADD)) {
        if (PropsValues.CAPTCHA_CHECK_PORTAL_CREATE_ACCOUNT) {
          CaptchaUtil.check(actionRequest);
        }

        addUser(actionRequest, actionResponse);
      } else if (cmd.equals(Constants.RESET)) {
        resetUser(actionRequest, actionResponse);
      } else if (cmd.equals(Constants.UPDATE)) {
        updateIncompleteUser(actionRequest, actionResponse);
      }
    } catch (Exception e) {
      if (e instanceof UserEmailAddressException.MustNotBeDuplicate
          || e instanceof UserScreenNameException.MustNotBeDuplicate) {

        String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");

        User user =
            _userLocalService.fetchUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress);

        if ((user == null) || (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) {

          SessionErrors.add(actionRequest, e.getClass(), e);
        } else {
          actionResponse.setRenderParameter("mvcPath", "/update_account.jsp");
        }
      } else if (e instanceof AddressCityException
          || e instanceof AddressStreetException
          || e instanceof AddressZipException
          || e instanceof CaptchaConfigurationException
          || e instanceof CaptchaTextException
          || e instanceof CompanyMaxUsersException
          || e instanceof ContactBirthdayException
          || e instanceof ContactNameException
          || e instanceof DuplicateOpenIdException
          || e instanceof EmailAddressException
          || e instanceof GroupFriendlyURLException
          || e instanceof NoSuchCountryException
          || e instanceof NoSuchListTypeException
          || e instanceof NoSuchOrganizationException
          || e instanceof NoSuchRegionException
          || e instanceof OrganizationParentException
          || e instanceof PhoneNumberException
          || e instanceof RequiredFieldException
          || e instanceof RequiredUserException
          || e instanceof TermsOfUseException
          || e instanceof UserEmailAddressException
          || e instanceof UserIdException
          || e instanceof UserPasswordException
          || e instanceof UserScreenNameException
          || e instanceof UserSmsException
          || e instanceof WebsiteURLException) {

        SessionErrors.add(actionRequest, e.getClass(), e);
      } else {
        throw e;
      }
    }

    if (Validator.isNull(PropsValues.COMPANY_SECURITY_STRANGERS_URL)) {
      return;
    }

    try {
      Layout layout =
          _layoutLocalService.getFriendlyURLLayout(
              themeDisplay.getScopeGroupId(), false, PropsValues.COMPANY_SECURITY_STRANGERS_URL);

      String redirect = PortalUtil.getLayoutURL(layout, themeDisplay);

      sendRedirect(actionRequest, actionResponse, redirect);
    } catch (NoSuchLayoutException nsle) {
    }
  }