...
|
...
|
@@ -10,6 +10,11 @@ package com.agent.controller.system; |
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
import com.agent.entity.system.FunctionEntity;
|
|
|
import com.agent.vo.MenuVo;
|
|
|
import com.framework.util.PropertiesLoader;
|
|
|
import com.framework.util.StringUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.apache.shiro.authc.IncorrectCredentialsException;
|
|
|
import org.apache.shiro.authc.LockedAccountException;
|
...
|
...
|
@@ -18,6 +23,7 @@ import org.apache.shiro.authc.UsernamePasswordToken; |
|
|
import org.apache.shiro.subject.Subject;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
...
|
...
|
@@ -39,6 +45,9 @@ import com.framework.util.MD5Tools; |
|
|
import login.FLogin;
|
|
|
import login.LoginData;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Controller
|
|
|
public class LoginController {
|
|
|
|
...
|
...
|
@@ -144,13 +153,15 @@ public class LoginController { |
|
|
@RequestMapping(value = "/doLogin", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public ResponseModel doLogin(String loginAccount, String password, String captcha) {
|
|
|
|
|
|
SessionUtil.putKey(Constants.CAPTCHA, "");
|
|
|
ResponseModel rm = new ResponseModel(200, "", null);
|
|
|
|
|
|
UserEntity user = new UserEntity();
|
|
|
user.setLoginaccount(loginAccount);
|
|
|
user.setPassword(password);
|
|
|
if (!loginAccount.equals("admin")) {
|
|
|
|
|
|
if (!loginAccount.equals("admin") && "true".equals(PropertiesLoader.getLogin("openRemoteLogin"))) {
|
|
|
// 远程登录
|
|
|
// 用户数据
|
|
|
LoginData login = FLogin.login(user);
|
...
|
...
|
@@ -235,6 +246,7 @@ public class LoginController { |
|
|
return rm;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 登录操作api
|
|
|
*
|
...
|
...
|
@@ -262,41 +274,6 @@ public class LoginController { |
|
|
UserEntity user = new UserEntity();
|
|
|
user.setLoginaccount(j.get("appLoginID").toString());
|
|
|
user.setPassword(j.get("appLoginPass").toString());
|
|
|
if (!j.get("appLoginID").toString().equals("admin")) {}
|
|
|
// 远程登录
|
|
|
// 用户数据
|
|
|
LoginData login = FLogin.login(user);
|
|
|
// 登录成功!
|
|
|
if (login.getCode() == 20000) {
|
|
|
// 往数据库中插入数据
|
|
|
UserEntity ue = userService.findByLoginaccount(user.getLoginaccount());
|
|
|
// 用户存在
|
|
|
if (ue != null) {
|
|
|
// 修改密码
|
|
|
userService.updatePassword(ue.getLoginaccount(), MD5Tools.MD5(j.get("appLoginPass").toString()));
|
|
|
} else {
|
|
|
// 用户不存在,插入数据
|
|
|
BasicAgentEntity agent = new BasicAgentEntity();
|
|
|
agent.setContact(login.getInfodata().getContact());
|
|
|
agent.setNameCn(login.getInfodata().getCompany());
|
|
|
agent.setCountryCode("CN");
|
|
|
agent.setAddress(login.getInfodata().getAddress());
|
|
|
int agent_id = agentSerive.save2(agent);
|
|
|
|
|
|
ue = new UserEntity();
|
|
|
ue.setLoginaccount(j.get("appLoginID").toString());
|
|
|
// 设置用户名密码
|
|
|
ue.setPassword(MD5Tools.MD5(j.get("appLoginPass").toString()));
|
|
|
ue.setRealName(login.getInfodata().getContact());
|
|
|
ue.setMobile(login.getInfodata().getMobile());
|
|
|
ue.setStatus(0);
|
|
|
ue.setAgent(new Long(agent_id));
|
|
|
RoleEntity re = new RoleEntity();
|
|
|
re.setId(new Long(1));
|
|
|
ue.setRole(re);
|
|
|
// 删除密码
|
|
|
userService.save(ue);
|
|
|
}
|
|
|
|
|
|
// 登录用户
|
|
|
Subject subject = SecurityUtils.getSubject();
|
...
|
...
|
@@ -326,7 +303,7 @@ public class LoginController { |
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "login";
|
|
|
}
|
|
|
} |
...
|
...
|
|