...
|
...
|
@@ -5,6 +5,7 @@ import com.ui.User.MD5Util; |
|
|
import com.ui.User.UserAuthLocal;
|
|
|
import com.ui.contants.HttpUriContants;
|
|
|
import com.ui.http.HttpRestClient;
|
|
|
import com.ui.ldaputil.LdapAuthUtil;
|
|
|
import com.ui.model.BaseResponse;
|
|
|
import com.ui.model.Directional;
|
|
|
import com.ui.model.req.AuthModule;
|
...
|
...
|
@@ -45,6 +46,9 @@ public class UserCtrl { |
|
|
@Autowired
|
|
|
UserAuthLocal userAuthLocal;
|
|
|
|
|
|
@Autowired
|
|
|
private LdapAuthUtil ldapAuthenticate;
|
|
|
|
|
|
@RequestMapping("/toLogin")
|
|
|
public ModelAndView toLogin() {
|
|
|
return new ModelAndView("user/login");
|
...
|
...
|
@@ -66,13 +70,50 @@ public class UserCtrl { |
|
|
|
|
|
}
|
|
|
|
|
|
User u = userAuthLocal.getUserByname(user.getName());
|
|
|
boolean ldapFlag=false;
|
|
|
// 给admin留一个后门,防止ldap不能验证
|
|
|
if(!"admin".equals(user.getName())){
|
|
|
ldapFlag=true;
|
|
|
}
|
|
|
|
|
|
User u =null;
|
|
|
if(ldapFlag){
|
|
|
//走ldap统一认证接口
|
|
|
//认证
|
|
|
//认证不通过,提示
|
|
|
if(!ldapAuthenticate.login(user.getName(),user.getPwd())){
|
|
|
model.addAttribute("message", "请使用你的OA账户登陆,登录名或者密码错误");
|
|
|
return new ModelAndView("user/login");
|
|
|
}
|
|
|
|
|
|
//认证通过
|
|
|
u = userAuthLocal.getUserByLdapName(user.getName());
|
|
|
|
|
|
if (u == null) {
|
|
|
model.addAttribute("message", "用户名不存在");
|
|
|
//创建默认的用户
|
|
|
model.addAttribute("message", "用户名不存在,如有需要请联系管理员添加用户");
|
|
|
return new ModelAndView("user/login");
|
|
|
}
|
|
|
if (u.getPwd().equals(MD5Util.encryption(user.getPwd()))) {
|
|
|
|
|
|
|
|
|
}else{
|
|
|
u = userAuthLocal.getUserByname(user.getName());
|
|
|
|
|
|
if (u == null) {
|
|
|
model.addAttribute("message", "用户名不存在,如有需要请联系管理员添加用户");
|
|
|
return new ModelAndView("user/login");
|
|
|
}
|
|
|
|
|
|
if (!u.getPwd().equals(MD5Util.encryption(user.getPwd()))) {
|
|
|
model.addAttribute("message", "密码错误");
|
|
|
return new ModelAndView("user/login");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//用户放到session
|
|
|
session.setAttribute("user", u);
|
|
|
|
|
|
if(StringUtils.isBlank(Directional.getInstance().getLoginTargetUrl())){
|
|
|
return new ModelAndView("dashBoard/dashBoard");
|
|
|
}else{
|
...
|
...
|
@@ -84,10 +125,6 @@ public class UserCtrl { |
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
} else {
|
|
|
model.addAttribute("message", "密码错误");
|
|
|
return new ModelAndView("user/login");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
|