|
@@ -6,6 +6,7 @@ import com.ui.User.UserAuthLocal; |
|
@@ -6,6 +6,7 @@ import com.ui.User.UserAuthLocal; |
6
|
import com.ui.contants.HttpUriContants;
|
6
|
import com.ui.contants.HttpUriContants;
|
7
|
import com.ui.http.HttpRestClient;
|
7
|
import com.ui.http.HttpRestClient;
|
8
|
import com.ui.model.BaseResponse;
|
8
|
import com.ui.model.BaseResponse;
|
|
|
9
|
+import com.ui.model.Directional;
|
9
|
import com.ui.model.req.AuthModule;
|
10
|
import com.ui.model.req.AuthModule;
|
10
|
import com.ui.model.req.User;
|
11
|
import com.ui.model.req.User;
|
11
|
import org.apache.commons.lang.RandomStringUtils;
|
12
|
import org.apache.commons.lang.RandomStringUtils;
|
|
@@ -18,9 +19,13 @@ import org.springframework.stereotype.Controller; |
|
@@ -18,9 +19,13 @@ import org.springframework.stereotype.Controller; |
18
|
import org.springframework.ui.Model;
|
19
|
import org.springframework.ui.Model;
|
19
|
import org.springframework.web.bind.annotation.RequestMapping;
|
20
|
import org.springframework.web.bind.annotation.RequestMapping;
|
20
|
import org.springframework.web.bind.annotation.ResponseBody;
|
21
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
22
|
+import org.springframework.web.client.RestTemplate;
|
21
|
import org.springframework.web.servlet.ModelAndView;
|
23
|
import org.springframework.web.servlet.ModelAndView;
|
22
|
|
24
|
|
|
|
25
|
+import javax.servlet.http.HttpServletResponse;
|
23
|
import javax.servlet.http.HttpSession;
|
26
|
import javax.servlet.http.HttpSession;
|
|
|
27
|
+
|
|
|
28
|
+import java.io.IOException;
|
24
|
import java.util.HashMap;
|
29
|
import java.util.HashMap;
|
25
|
import java.util.List;
|
30
|
import java.util.List;
|
26
|
import java.util.Map;
|
31
|
import java.util.Map;
|
|
@@ -32,7 +37,10 @@ public class UserCtrl { |
|
@@ -32,7 +37,10 @@ public class UserCtrl { |
32
|
Logger log = LoggerFactory.getLogger(UserCtrl.class);
|
37
|
Logger log = LoggerFactory.getLogger(UserCtrl.class);
|
33
|
|
38
|
|
34
|
@Autowired
|
39
|
@Autowired
|
35
|
- HttpRestClient httpRestClient;
|
40
|
+ private RestTemplate restTemplate;
|
|
|
41
|
+
|
|
|
42
|
+ @Autowired
|
|
|
43
|
+ private HttpRestClient httpRestClient;
|
36
|
|
44
|
|
37
|
@Autowired
|
45
|
@Autowired
|
38
|
UserAuthLocal userAuthLocal;
|
46
|
UserAuthLocal userAuthLocal;
|
|
@@ -48,7 +56,7 @@ public class UserCtrl { |
|
@@ -48,7 +56,7 @@ public class UserCtrl { |
48
|
}
|
56
|
}
|
49
|
|
57
|
|
50
|
@RequestMapping("/login")
|
58
|
@RequestMapping("/login")
|
51
|
- public ModelAndView toLogin(User user, HttpSession session, Model model) {
|
59
|
+ public ModelAndView toLogin(User user, HttpSession session, Model model, HttpServletResponse response) {
|
52
|
if (StringUtils.isBlank(user.getName())){
|
60
|
if (StringUtils.isBlank(user.getName())){
|
53
|
if (session.getAttribute("user") == null){
|
61
|
if (session.getAttribute("user") == null){
|
54
|
return new ModelAndView("user/login");
|
62
|
return new ModelAndView("user/login");
|
|
@@ -65,7 +73,17 @@ public class UserCtrl { |
|
@@ -65,7 +73,17 @@ public class UserCtrl { |
65
|
}
|
73
|
}
|
66
|
if (u.getPwd().equals(MD5Util.encryption(user.getPwd()))) {
|
74
|
if (u.getPwd().equals(MD5Util.encryption(user.getPwd()))) {
|
67
|
session.setAttribute("user", u);
|
75
|
session.setAttribute("user", u);
|
68
|
- return new ModelAndView("dashBoard/dashBoard");
|
76
|
+ if(StringUtils.isBlank(Directional.getInstance().getLoginTargetUrl())){
|
|
|
77
|
+ return new ModelAndView("dashBoard/dashBoard");
|
|
|
78
|
+ }else{
|
|
|
79
|
+ try {
|
|
|
80
|
+ //直接跳转到初始的请求页面
|
|
|
81
|
+ response.sendRedirect(Directional.getInstance().getLoginTargetUrl());
|
|
|
82
|
+ } catch (IOException e) {
|
|
|
83
|
+ return new ModelAndView("dashBoard/dashBoard");
|
|
|
84
|
+ }
|
|
|
85
|
+ return null;
|
|
|
86
|
+ }
|
69
|
} else {
|
87
|
} else {
|
70
|
model.addAttribute("message", "密码错误");
|
88
|
model.addAttribute("message", "密码错误");
|
71
|
return new ModelAndView("user/login");
|
89
|
return new ModelAndView("user/login");
|