reimplement "fix flow for loggedout checkout" ( b25a9842e4 )
				
					
				
			This commit is contained in:
		@ -31,9 +31,14 @@ public class RequestController {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/login")
 | 
			
		||||
    public String loginPost(HttpServletResponse response) {
 | 
			
		||||
        response.addCookie(new Cookie("login", "true"));
 | 
			
		||||
      return "redirect:/";
 | 
			
		||||
    public String loginPost(HttpServletResponse response, @RequestParam(value = "goto", required = false) String gto) {
 | 
			
		||||
      response.addCookie(new Cookie("login", "true"));
 | 
			
		||||
 | 
			
		||||
      if (gto != null && gto.startsWith("/")) {
 | 
			
		||||
           return "redirect:" + gto;
 | 
			
		||||
      } else {
 | 
			
		||||
           return "redirect:/";
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/logout")
 | 
			
		||||
@ -77,8 +82,12 @@ public class RequestController {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @PostMapping("/shop/articles/{id}")
 | 
			
		||||
     public String shopArticlesByIdBuy(HttpServletResponse response) {
 | 
			
		||||
         return "redirect:/shop/checkout";
 | 
			
		||||
     public String shopArticlesByIdBuy(@RequestAttribute("customer") Boolean isCustomer, @PathVariable("id") Integer id) {
 | 
			
		||||
        if (isCustomer) {
 | 
			
		||||
           return "redirect:/shop/checkout";
 | 
			
		||||
        } else {
 | 
			
		||||
           return "redirect:/login?goto=%2Fshop%2Farticles%2F"+id;
 | 
			
		||||
        }
 | 
			
		||||
     }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/user/")
 | 
			
		||||
 | 
			
		||||
@ -21,10 +21,11 @@ public class LoginIntercepter implements HandlerInterceptor {
 | 
			
		||||
            for (Cookie c : cookies) {
 | 
			
		||||
                if (c.getName().equals("login")) {
 | 
			
		||||
                    request.setAttribute("customer", c.getValue().equals("true"));
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        request.setAttribute("customer", false);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    @Override
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user