@RequestMapping(value="/register", method=RequestMethod.POST) protected String register(@Valid @ModelAttribute("customer") Customer customer, BindingResult result, Model model, RedirectAttributes redirectAttributes) { customerValidator.validate(customer, result); if(result.hasErrors()){ return "register"; } String password = customer.getPassword(); String encodedPwd = passwordEncoder.encode(password); customer.setPassword(encodedPwd); Customer persistedCustomer = customerService.createCustomer(customer); logger.debug("Created new Customer with id : {} and email : {}", persistedCustomer.getId(), persistedCustomer.getEmail()); redirectAttributes.addFlashAttribute("info", "Customer created successfully"); return "redirect:/login"; }
@RequestMapping(value="/register", method=RequestMethod.GET) protected String registerForm(Model model) { model.addAttribute("customer", new Customer()); return "register"; }
public AuthenticatedUser(Customer customer) { super(customer.getEmail(), customer.getPassword(), getAuthorities(customer)); this.customer = customer; } public Customer getCustomer()
@Override public void validate(Object target, Errors errors) { Customer customer = (Customer) target; Customer customerByEmail = custmoerService.getCustomerByEmail(customer.getEmail()); if(customerByEmail != null){ errors.rejectValue("email", "error.exists", new Object[]{customer.getEmail()}, "Email "+customer.getEmail()+" already in use"); } }
@RequestMapping(value="/myAccount", method=RequestMethod.GET) protected String myAccount(Model model) { String email = getCurrentUser().getCustomer().getEmail(); Customer customer = customerService.getCustomerByEmail(email); model.addAttribute("customer", customer); List<Order> orders = customerService.getCustomerOrders(email); model.addAttribute("orders", orders); return "myAccount"; } }
protected void sendOrderConfirmationEmail(Order order) { try { emailService.sendEmail(order.getCustomer().getEmail(), "QuilCartCart - Order Confirmation", "Your order has been placed successfully.\n" + "Order Number : "+order.getOrderNumber()); } catch (JCartException e) { logger.error(e); } }
public Cart() { items = new ArrayList<LineItem>(); customer = new Customer(); deliveryAddress = new Address(); payment = new Payment(); }
protected void sendOrderStatusUpdateEmail(Order order) { try { // Prepare the evaluation context final Context ctx = new Context(); ctx.setVariable("order", order); // Create the HTML body using Thymeleaf final String htmlContent = this.templateEngine.process("order-status-update-email", ctx); emailService.sendEmail(order.getCustomer().getEmail(), "QuilCartCart - Order Status Update", htmlContent); } catch (JCartException e) { logger.error(e); } } }
String email = getCurrentUser().getCustomer().getEmail(); Customer customer = customerService.getCustomerByEmail(email); newOrder.setCustomer(customer);