fix flow for loggedout checkout

This commit is contained in:
CodeSteak 2020-01-26 13:47:54 +01:00
parent f53a442fa6
commit b25a9842e4
2 changed files with 16 additions and 5 deletions

View File

@ -29,9 +29,16 @@ 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"));
return "redirect:/";
System.out.println(gto);
if (gto != null && gto.startsWith("/")) {
return "redirect:" + gto;
} else {
return "redirect:/";
}
}
@PostMapping("/logout")
@ -75,8 +82,12 @@ public class RequestController {
}
@PostMapping("/shop/articles/{id}")
public String shopArticlesByIdBuy() {
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/")

View File

@ -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>