|
@@ -5,17 +5,28 @@ import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.http.useragent.UserAgent;
|
|
import cn.hutool.http.useragent.UserAgent;
|
|
|
import cn.hutool.http.useragent.UserAgentUtil;
|
|
import cn.hutool.http.useragent.UserAgentUtil;
|
|
|
import com.zhongzheng.common.constant.Constants;
|
|
import com.zhongzheng.common.constant.Constants;
|
|
|
|
|
+import com.zhongzheng.common.core.domain.model.LoginUser;
|
|
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
|
|
+import com.zhongzheng.common.exception.user.UserPasswordNotMatchException;
|
|
|
|
|
+import com.zhongzheng.common.utils.MessageUtils;
|
|
|
|
|
+import com.zhongzheng.framework.manager.AsyncManager;
|
|
|
|
|
+import com.zhongzheng.framework.manager.factory.AsyncFactory;
|
|
|
|
|
+import com.zhongzheng.modules.user.domain.User;
|
|
|
import com.zhongzheng.modules.user.entity.ClientLoginUser;
|
|
import com.zhongzheng.modules.user.entity.ClientLoginUser;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.common.utils.ip.AddressUtils;
|
|
import com.zhongzheng.common.utils.ip.AddressUtils;
|
|
|
import com.zhongzheng.common.utils.ip.IpUtils;
|
|
import com.zhongzheng.common.utils.ip.IpUtils;
|
|
|
|
|
+import com.zhongzheng.modules.user.service.IUserService;
|
|
|
import io.jsonwebtoken.Claims;
|
|
import io.jsonwebtoken.Claims;
|
|
|
import io.jsonwebtoken.Jwts;
|
|
import io.jsonwebtoken.Jwts;
|
|
|
import io.jsonwebtoken.SignatureAlgorithm;
|
|
import io.jsonwebtoken.SignatureAlgorithm;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
|
|
|
+import org.springframework.security.authentication.BadCredentialsException;
|
|
|
|
|
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
|
|
|
+import org.springframework.security.core.Authentication;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -53,6 +64,9 @@ public class WxTokenService
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IUserService iUserService;
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
private AuthenticationManager authenticationManager;
|
|
private AuthenticationManager authenticationManager;
|
|
|
|
|
|
|
@@ -63,6 +77,11 @@ public class WxTokenService
|
|
|
*/
|
|
*/
|
|
|
public ClientLoginUser getLoginUser(HttpServletRequest request)
|
|
public ClientLoginUser getLoginUser(HttpServletRequest request)
|
|
|
{
|
|
{
|
|
|
|
|
+ //测试用户
|
|
|
|
|
+ String test_token = request.getHeader("X-Auth-Token");
|
|
|
|
|
+ if("test".equals(test_token)){
|
|
|
|
|
+ return getTestUser();
|
|
|
|
|
+ }
|
|
|
// 获取请求携带的令牌
|
|
// 获取请求携带的令牌
|
|
|
String token = getToken(request);
|
|
String token = getToken(request);
|
|
|
if (Validator.isNotEmpty(token))
|
|
if (Validator.isNotEmpty(token))
|
|
@@ -77,7 +96,14 @@ public class WxTokenService
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ private ClientLoginUser getTestUser(){
|
|
|
|
|
+ String unionId = "oQ2yp56PgQ-PfwN4vxTZhR5eTpzk";
|
|
|
|
|
+ User user = iUserService.queryByUnionId(unionId);
|
|
|
|
|
+ ClientLoginUser loginUser = new ClientLoginUser();
|
|
|
|
|
+ loginUser.setUser(user);
|
|
|
|
|
+ loginUser.setExpireTime(System.currentTimeMillis()+200);
|
|
|
|
|
+ return loginUser;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 设置用户身份信息
|
|
* 设置用户身份信息
|