调整微信登录

This commit is contained in:
wenc000 2020-05-13 17:07:57 +08:00
parent e9d8315ef0
commit e119931fb4
3 changed files with 14 additions and 15 deletions

View File

@ -23,7 +23,6 @@ public class WechatMiniAppProperties {
private String grantType;
private String appKey;
private String appSecret;
private String configToken;
public Boolean getActive() {
return active;
@ -73,14 +72,6 @@ public class WechatMiniAppProperties {
this.appSecret = appSecret;
}
public String getConfigToken() {
return configToken == null ? "" : configToken;
}
public void setConfigToken(String configToken) {
this.configToken = configToken;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("{");
@ -96,8 +87,6 @@ public class WechatMiniAppProperties {
.append(appKey).append('\"');
sb.append(",\"appSecret\":\"")
.append(appSecret).append('\"');
sb.append(",\"configToken\":\"")
.append(configToken).append('\"');
sb.append('}');
return sb.toString();
}

View File

@ -34,8 +34,14 @@ public class WechatMiniAppFilter implements Filter {
private static final Logger LOG = LoggerFactory.getLogger(WechatMiniAppFilter.class);
private AntPathMatcher antPathMatcher;
private static final String WECHAT_MINI_APP_LOGIN_URL = String.format("/**%s/auth/login", ISystemConstant.WECHAT_MINI_APP_PREFIX);
/**
* 授权登录
*/
private static final String WECHAT_MINI_APP_AUTH_LOGIN_URL = String.format("/**%s/auth/login", ISystemConstant.WECHAT_MINI_APP_PREFIX);
/**
* 认证登录
*/
private static final String WECHAT_MINI_APP_SIGN_LOGIN_URL = String.format("/**%s/sign/login", ISystemConstant.WECHAT_MINI_APP_PREFIX);
/**
* 微信类放行
*/
@ -57,9 +63,10 @@ public class WechatMiniAppFilter implements Filter {
HttpServletResponse response = (HttpServletResponse) servletResponse;
String requestUri = request.getRequestURI();
boolean isLogin = antPathMatcher.match(WECHAT_MINI_APP_LOGIN_URL, requestUri);
boolean isLogin = antPathMatcher.match(WECHAT_MINI_APP_AUTH_LOGIN_URL, requestUri) ||
antPathMatcher.match(WECHAT_MINI_APP_SIGN_LOGIN_URL, requestUri);
if (isLogin) {
filterChain.doFilter(request, response);
return;
}

View File

@ -49,6 +49,9 @@ public class WechatMiniAppAuthServiceImpl implements IWechatMiniAppAuthService {
if (wechatMiniAppProperties == null) {
throw new SystemException("未有相关配置");
}
if (wechatMiniAppProperties.getActive() == null || !wechatMiniAppProperties.getActive()) {
throw new SystemException("未激活小程序配置");
}
Map<String, Object> params = new HashMap<>(2);
params.put("appid", wechatMiniAppProperties.getAppKey());
params.put("secret", wechatMiniAppProperties.getAppSecret());