aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www/controllers/Site.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-07 16:13:57 +0300
committerGravatar Vitaly Takmazov2022-12-07 17:38:55 +0300
commit5e0500933d2f805fe879ced9171c65839c72579b (patch)
tree60eeb84ac103c3f160dda3c2adbd1a10c489e8ec /src/main/java/com/juick/www/controllers/Site.java
parent206742aed99a20fea014c83408fb44ff36089351 (diff)
Login: use `Referer` header to redirect after the successful login
Diffstat (limited to 'src/main/java/com/juick/www/controllers/Site.java')
-rw-r--r--src/main/java/com/juick/www/controllers/Site.java15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/main/java/com/juick/www/controllers/Site.java b/src/main/java/com/juick/www/controllers/Site.java
index a0b8c5b0..aa6d574d 100644
--- a/src/main/java/com/juick/www/controllers/Site.java
+++ b/src/main/java/com/juick/www/controllers/Site.java
@@ -46,6 +46,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import javax.inject.Inject;
import java.net.URLEncoder;
@@ -96,10 +97,12 @@ public class Site {
}
@GetMapping("/login")
- public String getloginForm(@Visitor User visitor, HttpSession session,
- @RequestParam(required = false, defaultValue = "true") boolean redirect, ModelMap model) {
+ public String getloginForm(@Visitor User visitor,
+ @RequestParam(name = "retpath", required = false, defaultValue = "/") String retPath,
+ HttpSession session,
+ ModelMap model) {
if (!visitor.isAnonymous()) {
- return redirect ? "redirect:/" : "redirect:/login/success";
+ return String.format("redirect:%s", retPath);
}
model.addAttribute("visitor", visitor);
model.addAttribute("tags", tagService.getPopularTags());
@@ -119,12 +122,6 @@ public class Site {
return "views/login";
}
- @GetMapping("/login/success")
- public String getSuccessLogin(@Visitor User visitor, ModelMap model) {
- model.addAttribute("hash", userService.getHashByUID(visitor.getUid()));
- return "views/login_success";
- }
-
@GetMapping("/")
protected String doGet(@Visitor User visitor, Locale locale, @RequestParam(required = false) String tag,
@RequestParam(name = "show", required = false) String paramShow,