Ejemplo n.º 1
0
  private void logout(HttpServletRequest request) throws Exception {

    CustomerLogonModule logon =
        (CustomerLogonModule) com.salesmanager.core.util.SpringUtil.getBean("customerLogon");

    logon.logout(request);

    request.getSession().setAttribute("CUSTOMER", null);
  }
Ejemplo n.º 2
0
  public String execute(HttpServletRequest request) throws Exception {

    Customer customer = null;

    if (!validateCustomerLogon(request)) {

      LabelUtil l = LabelUtil.getInstance();
      Locale locale = LocaleUtil.getLocale(request);
      l.setLocale(locale);
      MessageUtil.addErrorMessage(request, l.getText(locale, "login.invalid"));
      return "redirect:/home.html";
    }
    try {

      CustomerLogonModule logon =
          (CustomerLogonModule) com.salesmanager.core.util.SpringUtil.getBean("customerLogon");

      // get merchantId
      int merchantId = 1;
      HttpSession session = request.getSession();
      MerchantStore store = (MerchantStore) session.getAttribute("STORE");
      if (store != null) {
        merchantId = store.getMerchantId();
      }

      customer = logon.logon(request, merchantId);

      if (customer == null) {

        MessageUtil.addErrorMessage(request, super.getText(request, "login.invalid"));
        return "redirect:/home.html";
      }

      Locale locale = LocaleUtil.getLocale(request);
      customer.setLocale(locale);

      // get CustomerInfo
      CustomerService cservice =
          (CustomerService) ServiceFactory.getService(ServiceFactory.CustomerService);
      CustomerInfo customerInfo = cservice.findCustomerInfoById(customer.getCustomerId());

      if (customerInfo == null) {
        customerInfo = new CustomerInfo();
        customerInfo.setCustomerInfoId(customer.getCustomerId());
      }

      Integer login = customerInfo.getCustomerInfoNumberOfLogon();
      login = login + 1;
      customerInfo.setCustomerInfoNumberOfLogon(login);
      cservice.saveOrUpdateCustomerInfo(customerInfo);

      SessionUtil.setCustomer(customer, request);
      request.setAttribute("CUSTOMER", customer);

      return "redirect:/profile/profile.html";

    } catch (ServiceException e) {

      MessageUtil.addErrorMessage(request, super.getText(request, "login.invalid"));
      return "redirect:/home.html";

    } catch (Exception ex) {
      log.error(ex);
      throw ex;
    }
  }