fix flow for loggedout checkout
This commit is contained in:
parent
f53a442fa6
commit
b25a9842e4
|
@ -29,10 +29,17 @@ public class RequestController {
|
|||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public String loginPost(HttpServletResponse response) {
|
||||
public String loginPost(HttpServletResponse response, @RequestParam(value = "goto", required = false) String gto) {
|
||||
response.addCookie(new Cookie("login", "true"));
|
||||
|
||||
System.out.println(gto);
|
||||
|
||||
if (gto != null && gto.startsWith("/")) {
|
||||
return "redirect:" + gto;
|
||||
} else {
|
||||
return "redirect:/";
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
public String logoutPost(HttpServletResponse response) {
|
||||
|
@ -75,8 +82,12 @@ public class RequestController {
|
|||
}
|
||||
|
||||
@PostMapping("/shop/articles/{id}")
|
||||
public String shopArticlesByIdBuy() {
|
||||
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/")
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<body>
|
||||
<!-- <nav th:replace="/fragments/header :: header">Header</nav> -->
|
||||
<main class="content-width modal">
|
||||
<form class="detailgrid s hero " method="post" th:action="@{/login}">
|
||||
<form class="detailgrid s hero " method="post">
|
||||
<div class="s">
|
||||
<label for="username">Email Adresse</label>
|
||||
<input class="full-width" type="text" name="username" placeholder="Email Adresse" id="username" required>
|
||||
|
|
Reference in New Issue