作者 申海龙

修改系统的登录流程

@@ -10,6 +10,9 @@ package com.agent.controller.system; @@ -10,6 +10,9 @@ package com.agent.controller.system;
10 import javax.annotation.Resource; 10 import javax.annotation.Resource;
11 import javax.servlet.http.HttpServletRequest; 11 import javax.servlet.http.HttpServletRequest;
12 12
  13 +
  14 +import com.framework.util.PropertiesLoader;
  15 +import com.framework.util.StringUtils;
13 import org.apache.shiro.SecurityUtils; 16 import org.apache.shiro.SecurityUtils;
14 import org.apache.shiro.authc.IncorrectCredentialsException; 17 import org.apache.shiro.authc.IncorrectCredentialsException;
15 import org.apache.shiro.authc.LockedAccountException; 18 import org.apache.shiro.authc.LockedAccountException;
@@ -18,6 +21,7 @@ import org.apache.shiro.authc.UsernamePasswordToken; @@ -18,6 +21,7 @@ import org.apache.shiro.authc.UsernamePasswordToken;
18 import org.apache.shiro.subject.Subject; 21 import org.apache.shiro.subject.Subject;
19 import org.springframework.stereotype.Controller; 22 import org.springframework.stereotype.Controller;
20 import org.springframework.transaction.annotation.Transactional; 23 import org.springframework.transaction.annotation.Transactional;
  24 +import org.springframework.web.bind.annotation.RequestBody;
21 import org.springframework.web.bind.annotation.RequestMapping; 25 import org.springframework.web.bind.annotation.RequestMapping;
22 import org.springframework.web.bind.annotation.RequestMethod; 26 import org.springframework.web.bind.annotation.RequestMethod;
23 import org.springframework.web.bind.annotation.ResponseBody; 27 import org.springframework.web.bind.annotation.ResponseBody;
@@ -39,6 +43,8 @@ import com.framework.util.MD5Tools; @@ -39,6 +43,8 @@ import com.framework.util.MD5Tools;
39 import login.FLogin; 43 import login.FLogin;
40 import login.LoginData; 44 import login.LoginData;
41 45
  46 +import java.util.Map;
  47 +
42 @Controller 48 @Controller
43 public class LoginController { 49 public class LoginController {
44 50
@@ -144,13 +150,14 @@ public class LoginController { @@ -144,13 +150,14 @@ public class LoginController {
144 @RequestMapping(value = "/doLogin", method = RequestMethod.POST) 150 @RequestMapping(value = "/doLogin", method = RequestMethod.POST)
145 @ResponseBody 151 @ResponseBody
146 public ResponseModel doLogin(String loginAccount, String password, String captcha) { 152 public ResponseModel doLogin(String loginAccount, String password, String captcha) {
  153 +
147 SessionUtil.putKey(Constants.CAPTCHA, ""); 154 SessionUtil.putKey(Constants.CAPTCHA, "");
148 ResponseModel rm = new ResponseModel(200, "", null); 155 ResponseModel rm = new ResponseModel(200, "", null);
149 156
150 UserEntity user = new UserEntity(); 157 UserEntity user = new UserEntity();
151 user.setLoginaccount(loginAccount); 158 user.setLoginaccount(loginAccount);
152 user.setPassword(password); 159 user.setPassword(password);
153 - if (!loginAccount.equals("admin")) { 160 + if (!loginAccount.equals("admin") && loginAccount.equals(PropertiesLoader.getLogin("openRemoteLogin"))) {
154 // 远程登录 161 // 远程登录
155 // 用户数据 162 // 用户数据
156 LoginData login = FLogin.login(user); 163 LoginData login = FLogin.login(user);
@@ -224,20 +231,21 @@ public class LoginController { @@ -224,20 +231,21 @@ public class LoginController {
224 rm.setStatus(500); 231 rm.setStatus(500);
225 rm.setMsg("1"); 232 rm.setMsg("1");
226 } catch (IncorrectCredentialsException e) { 233 } catch (IncorrectCredentialsException e) {
227 - rm.setStatus(500);  
228 - rm.setMsg("1");  
229 - } catch (LockedAccountException e) {  
230 - rm.setStatus(500);  
231 - rm.setMsg("1");  
232 - } 234 + rm.setStatus(500);
  235 + rm.setMsg("1");
  236 + } catch (LockedAccountException e) {
  237 + rm.setStatus(500);
  238 + rm.setMsg("1");
233 } 239 }
  240 + }
234 241
235 return rm; 242 return rm;
236 } 243 }
237 - 244 +
  245 +
238 /** 246 /**
239 * 登录操作api 247 * 登录操作api
240 - * 248 + *
241 * @return 249 * @return
242 */ 250 */
243 @RequestMapping(value = "/loginApi", method = RequestMethod.POST) 251 @RequestMapping(value = "/loginApi", method = RequestMethod.POST)
@@ -22,6 +22,8 @@ public class PropertiesLoader { @@ -22,6 +22,8 @@ public class PropertiesLoader {
22 private static final String CONFIG_FILE = "/config.properties"; 22 private static final String CONFIG_FILE = "/config.properties";
23 23
24 private static final String REDIS_FILE = "/redis.properties"; 24 private static final String REDIS_FILE = "/redis.properties";
  25 +
  26 + private static final String LOGIN_FILE = "/openRemoteLogin.properties";
25 27
26 /** 28 /**
27 * 配置文件properties获取value 29 * 配置文件properties获取value
@@ -63,6 +65,12 @@ public class PropertiesLoader { @@ -63,6 +65,12 @@ public class PropertiesLoader {
63 } 65 }
64 66
65 67
  68 + public static String getLogin(String key) {
  69 + Properties properties = PropertiesLoader.loadProperty(LOGIN_FILE);
  70 + return properties.getProperty(key);
  71 + }
  72 +
  73 +
66 public static String get(String key,String propertyFile){ 74 public static String get(String key,String propertyFile){
67 Properties properties = loadProperty(propertyFile); 75 Properties properties = loadProperty(propertyFile);
68 return (String) properties.get(key); 76 return (String) properties.get(key);
  1 +#ǷԶ̵¼
  2 +openRemoteLogin = true