diff options
author | Vitaly Takmazov | 2018-03-02 14:54:23 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-03-02 12:44:39 +0000 |
commit | f17f861e292988327f5084e578f5a0e512033553 (patch) | |
tree | 8e8821fba6d86ee4f3be448193e0331f7d7b4764 /juick-www/src/main/java | |
parent | 15790c737b87b528f3a8eda4d4cb559220223bd6 (diff) |
www: blank redirect for js login
Diffstat (limited to 'juick-www/src/main/java')
-rw-r--r-- | juick-www/src/main/java/com/juick/www/controllers/Login.java | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/Login.java b/juick-www/src/main/java/com/juick/www/controllers/Login.java index ff58e8d0..cb7df833 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/Login.java +++ b/juick-www/src/main/java/com/juick/www/controllers/Login.java @@ -17,22 +17,34 @@ package com.juick.www.controllers; import com.juick.server.util.UserUtils; +import com.juick.service.UserService; import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.inject.Inject; /** * @author Ugnich Anton */ @Controller public class Login { + @Inject + private UserService userService; @GetMapping("/login") - public String getloginForm() { + public String getloginForm(@RequestParam(required = false, defaultValue = "true") boolean redirect) { com.juick.User visitor = UserUtils.getCurrentUser(); - if (!visitor.isAnonymous()) - return "redirect:/"; - + if (!visitor.isAnonymous()) { + return redirect ? "redirect:/" : "redirect:/login/success"; + } return "views/login"; } + @GetMapping("/login/success") + public String getSuccessLogin(ModelMap model) { + model.addAttribute("hash", userService.getHashByUID(UserUtils.getCurrentUser().getUid())); + return "views/login_success"; + } } |