|
@@ -28,6 +28,7 @@ import com.jeeplus.sys.utils.UserUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.compress.utils.Lists;
|
|
|
import org.jasig.cas.client.authentication.AttributePrincipal;
|
|
|
import org.jasig.cas.client.validation.Assertion;
|
|
|
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
|
|
@@ -52,6 +53,7 @@ import javax.servlet.http.HttpSession;
|
|
|
import java.io.IOException;
|
|
|
import java.nio.file.AccessDeniedException;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
/**
|
|
@@ -83,18 +85,19 @@ public class LoginController {
|
|
|
@ApiOperation("登录接口")
|
|
|
public ResponseEntity login(@RequestBody LoginForm loginForm) {
|
|
|
ResponseUtil responseUtil = new ResponseUtil ( );
|
|
|
+ String loginUserName = loginForm.getUsername ();
|
|
|
String username = loginForm.getUsername ();
|
|
|
String password = loginForm.getPassword ();
|
|
|
String code = loginForm.getCode ();
|
|
|
- Integer redisLoginNumber = (Integer) RedisUtils.getInstance ().get ( CacheNames.USER_CACHE_LOGIN_CODE + username );
|
|
|
+ Integer redisLoginNumber = (Integer) RedisUtils.getInstance ().get ( CacheNames.USER_CACHE_LOGIN_CODE + loginUserName );
|
|
|
if(null == redisLoginNumber){
|
|
|
redisLoginNumber = 0;
|
|
|
}else{
|
|
|
redisLoginNumber ++ ;
|
|
|
}
|
|
|
- RedisUtils.getInstance().set(CacheNames.USER_CACHE_LOGIN_CODE + username , redisLoginNumber);
|
|
|
+ RedisUtils.getInstance().set(CacheNames.USER_CACHE_LOGIN_CODE + loginUserName , redisLoginNumber);
|
|
|
//给登录次数记录设置6小时的过期时间
|
|
|
- RedisUtils.getInstance().expire(CacheNames.USER_CACHE_LOGIN_CODE + username , 21600);
|
|
|
+ RedisUtils.getInstance().expire(CacheNames.USER_CACHE_LOGIN_CODE + loginUserName , 21600);
|
|
|
|
|
|
String dictValue = DictUtils.getDictLabel("login_number", "login_verification_number", null);
|
|
|
//字典中限制显示次数
|
|
@@ -107,6 +110,16 @@ public class LoginController {
|
|
|
throw new AccountExpiredException ( ErrorConstants.LOGIN_ERROR_ERROR_VALIDATE_CODE );
|
|
|
}
|
|
|
}
|
|
|
+ //根据登录名查询登录信息
|
|
|
+ List<UserDTO> loginUserList = userService.getUserIdByLoginOrMobile(username);
|
|
|
+ if(null != loginUserList){
|
|
|
+ if (loginUserList.size()>1){
|
|
|
+ throw new DisabledException ( "登录名重复,请使用手机号登录" );
|
|
|
+ }else{
|
|
|
+ username = loginUserList.get(0).getLoginName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
SecurityUtils.login (username, password, authenticationManager ); //登录操作spring security
|
|
|
|
|
|
/**
|
|
@@ -124,7 +137,7 @@ public class LoginController {
|
|
|
updateUserLoginInfo ( responseUtil, userDTO , token);
|
|
|
|
|
|
//删除redis中登录次数的信息
|
|
|
- RedisUtils.getInstance ().delete ( CacheNames.USER_CACHE_LOGIN_CODE + username );
|
|
|
+ RedisUtils.getInstance ().delete ( CacheNames.USER_CACHE_LOGIN_CODE + loginUserName );
|
|
|
|
|
|
return responseUtil.ok ( );
|
|
|
}
|