|
|
@@ -1,6 +1,7 @@
|
|
|
package com.inspur.smsb.gateway.filter;
|
|
|
|
|
|
import com.alibaba.cola.dto.SingleResponse;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.base.Strings;
|
|
|
import com.inspur.smsb.gateway.dto.KeycloakUserDto;
|
|
|
@@ -57,8 +58,15 @@ public class WebFluxUserRequestInfoFilter implements GlobalFilter {
|
|
|
List<KeycloakUserDto> list = queryUsers(url, token);
|
|
|
list = list.stream().filter(keycloakUserDto -> {
|
|
|
Map attributes = keycloakUserDto.getAttributes();
|
|
|
- String openid = Optional.ofNullable(attributes.get("wechat-applet-openid")).orElse("").toString();
|
|
|
- return StringUtils.hasText(openid) && openid.equals(wxAppletId);
|
|
|
+ if (attributes == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ JSONArray array = (JSONArray) attributes.get("wechat-applet-openid");
|
|
|
+ String openIdAttr = "";
|
|
|
+ if (array != null && !array.isEmpty()) {
|
|
|
+ openIdAttr = array.getString(0);
|
|
|
+ }
|
|
|
+ return StringUtils.hasText(openIdAttr) && openIdAttr.equals(wxAppletId);
|
|
|
}).collect(Collectors.toList());
|
|
|
if (!list.isEmpty()) {
|
|
|
String userId = list.get(0).getId();
|