public String doIclubLogin() {
    LOGGER.info("Class :: " + this.getClass() + " :: Method :: doIclubLogin");
    if (!validateLogin()) {
      try {
        WebClient client =
            IclubWebHelper.createCustomClient(
                BASE_URL
                    + "person/login/"
                    + bean.getLName()
                    + "/"
                    + Base64.encodeBase64URLSafeString(DigestUtils.md5(bean.getLPasswd())));
        ResponseModel response = client.accept(MediaType.APPLICATION_JSON).get(ResponseModel.class);
        client.close();
        if (response.getStatusCode() == 0) {
          setTheme();
          IclubWebHelper.addMessage("Person Logged-In successfully", FacesMessage.SEVERITY_INFO);
          WebClient loginClient =
              IclubWebHelper.createCustomClient(BASE_URL + "person/" + bean.getLName());
          IclubLoginModel model =
              loginClient.accept(MediaType.APPLICATION_JSON).get(IclubLoginModel.class);
          loginClient.close();
          if (model != null && model.getLId() != null) {
            IclubWebHelper.addObjectIntoSession(
                BUNDLE.getString("logged.in.user.id"), model.getIclubPersonBByLPersonId());
            IclubWebHelper.addObjectIntoSession(
                BUNDLE.getString("logged.in.user.scname"), bean.getLName());
            WebClient personClient =
                IclubWebHelper.createCustomClient(
                    U_BASE_URL + "get/" + model.getIclubPersonBByLPersonId());
            IclubPersonModel personModel =
                personClient.accept(MediaType.APPLICATION_JSON).get(IclubPersonModel.class);
            personClient.close();
            IclubWebHelper.addObjectIntoSession(
                BUNDLE.getString("logged.in.user.name"),
                personModel.getPFName()
                    + (personModel.getPLName() == null ? "" : personModel.getPLName() + " "));
            IclubWebHelper.addObjectIntoSession(
                BUNDLE.getString("logged.in.role.id"), model.getIclubRoleType());

            return "/pages/dashboard/user/main.xhtml?faces-redirect=true";

          } else {
            IclubWebHelper.addMessage(
                "Person Profile Fetch Error - Contact Admin", FacesMessage.SEVERITY_ERROR);
            return "";
          }
        } else {
          IclubWebHelper.addMessage(
              "Login error :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR);
          return "";
        }
      } catch (Exception e) {
        LOGGER.error(e, e);
        IclubWebHelper.addMessage("Login error :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR);
        return "";
      }
    } else {
      return "";
    }
  }
  public static void setTheme() {
    String viewId = FacesContext.getCurrentInstance().getViewRoot().getViewId();

    if (viewId != null && viewId.contains("spark")) {

      IclubWebHelper.addObjectIntoSession(BUNDLE.getString("logged.in.user.theme"), "-spark");
      IclubWebHelper.addObjectIntoSession(BUNDLE.getString("logged.in.user.webTheme"), "spark");

    } else {
      IclubWebHelper.addObjectIntoSession(BUNDLE.getString("logged.in.user.theme"), "");
      IclubWebHelper.addObjectIntoSession(BUNDLE.getString("logged.in.user.webTheme"), "sentinel");
    }
  }
  public void doIclubLogout() {

    String theme = "";
    String webTheme = "";
    if (IclubWebHelper.getObjectIntoSession(BUNDLE.getString("logged.in.user.theme")) != null) {
      theme =
          IclubWebHelper.getObjectIntoSession(BUNDLE.getString("logged.in.user.theme")).toString();
    }
    if (IclubWebHelper.getObjectIntoSession(BUNDLE.getString("logged.in.user.webTheme")) != null) {
      webTheme =
          IclubWebHelper.getObjectIntoSession(BUNDLE.getString("logged.in.user.webTheme"))
              .toString();
    }
    IclubWebHelper.invalidateSession();
    IclubWebHelper.addObjectIntoSession(BUNDLE.getString("logged.in.user.theme"), theme);
    IclubWebHelper.addObjectIntoSession(BUNDLE.getString("logged.in.user.webTheme"), webTheme);
    FacesContext context = FacesContext.getCurrentInstance();
    NavigationHandler navigationHandler = context.getApplication().getNavigationHandler();

    navigationHandler.handleNavigation(
        context, null, "/templates/login" + theme + ".xhtml?faces-redirect=true");

    String url = "https://testclientapi.fraudcheck.co.za/api/authenticate/test";
    String currentDate = System.currentTimeMillis() + "";

    String fcHash = DigestUtils.md5Hex(FRAUD_CHECK_USERID + FRAUD_CHECK_PWD + currentDate);

    HttpClient client = getHttpClient();

    try {
      HttpPost post = new HttpPost(url);
      post.setHeader("Content-Type", "application/json");
      post.setHeader("FcAccId", FRAUD_CHECK_USERID);
      post.setHeader("FcHash", fcHash);
      post.setHeader("FcDate", currentDate);

      List<NameValuePair> arguments = new ArrayList<>(3);
      arguments.add(new BasicNameValuePair("data", "test"));
      post.setEntity(new UrlEncodedFormEntity(arguments));
      HttpResponse response1 = client.execute(post);
      EntityUtils.toString(response1.getEntity());
    } catch (Exception e) {
      LOGGER.error(e, e);
    }
  }
  public String updateLogin() {

    try {
      if (validateLoginForm(!updateLogin)) {
        IclubLoginModel model = new IclubLoginModel();
        WebClient client = null;

        if (loginBean.getLId() != null) {
          client = IclubWebHelper.createCustomClient(LOG_BASE_URL + "mod");
          model.setLId(loginBean.getLId());

        } else {
          client = IclubWebHelper.createCustomClient(LOG_BASE_URL + "add");
          model.setLId(UUID.randomUUID().toString());
        }
        model.setLCrtdDt(new Date(System.currentTimeMillis()));
        model = IclubLoginTrans.fromUItoWS(loginBean);

        model.setLPasswd(Base64.encodeBase64URLSafeString(DigestUtils.md5(loginBean.getLPasswd())));
        model.setIclubPersonAByLCrtdBy(bean.getPId());
        model.setIclubPersonBByLPersonId(getSessionUserId());
        model.setIclubRoleType(2l);

        ResponseModel response = null;
        if (updateLogin) {
          response = client.accept(MediaType.APPLICATION_JSON).put(model, ResponseModel.class);
        } else {
          response = client.accept(MediaType.APPLICATION_JSON).post(model, ResponseModel.class);
        }

        if (response.getStatusCode() == 0) {
          IclubWebHelper.addObjectIntoSession("social_update_profile", null);
          IclubWebHelper.addMessage(
              "Personal Details Updated Successfully", FacesMessage.SEVERITY_INFO);
          loadBean = false;
          return "userDashboard";
        } else {
          IclubWebHelper.addMessage(
              "Fail :: " + response.getStatusDesc(), FacesMessage.SEVERITY_ERROR);
        }
      }

    } catch (Exception e) {
      IclubWebHelper.addMessage("Fail :: " + e.getMessage(), FacesMessage.SEVERITY_ERROR);
    }
    return null;
  }
 public void newCohortInviteAction() {
   setTheme();
   IclubWebHelper.addObjectIntoSession("newInvite", "true");
 }