aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/controllers
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2017-04-05 17:36:38 +0700
committerGravatar Vitaly Takmazov2017-04-05 14:02:56 +0300
commita9a2c587a4de11ce04aaae7a0c1a5dab1430794a (patch)
treebd86b40c1fefc10b3fa30d370ce0cdee5ba4ee06 /juick-www/src/main/java/com/juick/www/controllers
parent4c99585f95cda1839f364524b6f68a16d063ed61 (diff)
login by hash, remember-me
Diffstat (limited to 'juick-www/src/main/java/com/juick/www/controllers')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/Login.java40
1 files changed, 9 insertions, 31 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 a83cbc16..8f9a993a 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
@@ -19,47 +19,25 @@ package com.juick.www.controllers;
import com.juick.service.UserService;
import com.juick.util.UserUtils;
-import com.juick.www.Utils;
-import com.juick.www.WebApp;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-import javax.inject.Inject;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
+import org.springframework.web.bind.annotation.GetMapping;
/**
- *
* @author Ugnich Anton
*/
@Controller
public class Login {
- @Inject
- UserService userService;
- @Inject
- WebApp webApp;
+ @Autowired
+ private UserService userService;
- @RequestMapping(value = "/login", method = RequestMethod.GET)
- protected String doGetLoginForm(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ @GetMapping("/login")
+ public String getloginForm() {
com.juick.User visitor = UserUtils.getCurrentUser();
- if (!visitor.isAnonymous()) {
+
+ if (!visitor.isAnonymous())
return "redirect:/";
- }
+
return "views/login";
}
- @RequestMapping(value="/logout", method = RequestMethod.GET)
- public String logoutPage (HttpServletRequest request, HttpServletResponse response) {
- Authentication auth = SecurityContextHolder.getContext().getAuthentication();
- if (auth != null){
- new SecurityContextLogoutHandler().logout(request, response, auth);
- }
- return "redirect:/login?logout";
- }
}