aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www/controllers
diff options
context:
space:
mode:
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";
- }
}