From d0cf2cb2c352bdeb146aad2bb57ba7d39cef3bbd Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 03 十一月 2026 17:59:04 +0800
Subject: [PATCH] 完善会员审批及门户配置
---
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java | 50 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
index dbdb45e..4f21422 100644
--- a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
+++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
@@ -40,6 +40,7 @@
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@@ -101,6 +102,10 @@
private RoleService roleService;
@Resource
private PermissionService permissionService;
+ @Autowired(required = false)
+ private WxcpMembershipRegistration wxcpMembershipRegistration;
+ @Resource
+ private WxcpPasswordSetupGrant wxcpPasswordSetupGrant;
/**
* 楠岃瘉鐮佺殑寮�鍏筹紝榛樿涓� true
@@ -118,6 +123,7 @@
createLoginLog(null, username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
throw exception(AUTH_LOGIN_BAD_CREDENTIALS);
}
+
if (!userService.isPasswordMatch(password, user.getPassword())) {
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
throw exception(AUTH_LOGIN_BAD_CREDENTIALS);
@@ -141,6 +147,14 @@
// 濡傛灉 socialType 闈炵┖锛岃鏄庨渶瑕佺粦瀹氱ぞ浜ょ敤鎴�
if (reqVO.getSocialType() != null) {
+ if (WECHAT_ENTERPRISE_TYPE.equals(reqVO.getSocialType())) {
+ SocialUserRespDTO social = socialUserService.getSocialUserByCode(getUserType().getValue(),
+ reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState());
+ if (wxcpMembershipRegistration == null || social == null
+ || wxcpMembershipRegistration.hasPendingApplication(social.getOpenid())) {
+ throw exception(AUTH_WXCP_MEMBERSHIP_PENDING);
+ }
+ }
socialUserService.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(),
reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState()));
}
@@ -219,27 +233,43 @@
}
// 2. 鍒ゆ柇鏄惁宸叉湁缁戝畾鐨勭郴缁熺敤鎴�
+ //
+ // 娉ㄦ剰锛歴ystem_social_user_bind 閲岀殑 user_id 鍙兘鎸囧悜銆屽凡琚垹闄ゃ�嶇殑鐢ㄦ埛 鈥斺��
+ // AdminUserServiceImpl.deleteUser 鍙竻鐞嗕簡瑙掕壊鍜屽矖浣嶏紝娌℃湁娓呯悊杩欏紶绀句氦缁戝畾琛紝
+ // 鍒犻櫎鍚庣粦瀹氬叧绯讳細娈嬬暀鎴愬鍎裤�傛墍浠ヨ繖閲屼笉鑳藉彧鐪嬨�屾湁娌℃湁缁戝畾銆嶏紝
+ // 杩樿鐪嬨�岀粦瀹氱殑浜鸿繕鍦ㄤ笉鍦ㄣ�嶃��
Long bindUserId = socialUser.getUserId();
- AdminUserDO user;
+ AdminUserDO user = bindUserId != null ? userService.getUser(bindUserId) : null;
- if (bindUserId == null) {
- // 2.1 棣栨鐧诲綍锛氳嚜鍔ㄦ敞鍐屾柊鐢ㄦ埛
+ if (user == null) {
+ if (WECHAT_ENTERPRISE_TYPE.equals(reqVO.getType())) {
+ if (wxcpMembershipRegistration == null) throw new IllegalStateException("浼氬憳娉ㄥ唽鏈嶅姟涓嶅彲鐢�");
+ wxcpMembershipRegistration.startIfAbsent(socialUser.getOpenid(), socialUser.getNickname(), socialUser.getMobile());
+ return null; // 鎻愪氦浜嬪姟鍚庣敱 Controller 杩斿洖寰呭鏍告彁绀猴紝涓嶇鍙戜护鐗�
+ }
+ // 2.1 棣栨鐧诲綍锛屾垨鍘熺粦瀹氱敤鎴峰凡琚垹闄わ細鑷姩娉ㄥ唽鏂扮敤鎴峰苟锛堟敼锛夌粦瀹�
+ //
+ // 鍘熺粦瀹氱敤鎴峰凡鍒犻櫎鏃跺繀椤昏蛋杩欐潯璺細鍚﹀垯璇ヤ紒涓氭垚鍛樹細姘镐箙鍗″湪銆岀敤鎴蜂笉瀛樺湪銆嶁�斺��
+ // 鏃㈢櫥涓嶈繘鏉ワ紝涔熶笉浼氳閲嶆柊娉ㄥ唽锛屾槸涓�涓棤娉曡嚜鎰堢殑姝婚攣銆�
+ // bindSocialUser 鍐呴儴浼氬厛鍒犳帀璇ョぞ浜ょ敤鎴风殑鏃х粦瀹氾紝鎵�浠ユ敼缁戜笉浼氫骇鐢熼噸澶嶈褰曘��
+ if (bindUserId != null) {
+ log.warn("[socialLogin][绀句氦鐢ㄦ埛({}) 鍘熺粦瀹氱殑鐢ㄦ埛({}) 宸蹭笉瀛樺湪锛堝彲鑳藉凡琚垹闄わ級锛屾寜棣栨鐧诲綍閲嶆柊娉ㄥ唽]",
+ socialUser.getOpenid(), bindUserId);
+ }
user = autoRegisterUser(socialUser, reqVO.getType());
// 缁戝畾绀句氦璐﹀彿
socialUserService.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(),
reqVO.getType(), reqVO.getCode(), reqVO.getState()));
log.info("[socialLogin][绀句氦鐧诲綍鑷姩娉ㄥ唽 userId={} username={} socialType={}]",
user.getId(), user.getUsername(), reqVO.getType());
- } else {
- // 2.2 宸叉湁缁戝畾锛氱洿鎺ヨ幏鍙栫敤鎴�
- user = userService.getUser(bindUserId);
- if (user == null) {
- throw exception(USER_NOT_EXISTS);
- }
}
+ if (CommonStatusEnum.isDisable(user.getStatus())) throw exception(AUTH_LOGIN_USER_DISABLED);
// 3. 鍒涘缓 Token 浠ょ墝锛岃褰曠櫥褰曟棩蹇�
AuthLoginRespVO result = createTokenAfterLoginSuccess(user.getId(), user.getUsername(), LoginLogTypeEnum.LOGIN_SOCIAL);
+ if (WECHAT_ENTERPRISE_TYPE.equals(reqVO.getType())) {
+ wxcpPasswordSetupGrant.issue(result.getAccessToken(), user.getId());
+ }
// 4. 鍙戝竷绀句氦鐧诲綍浜嬩欢锛堜緵鍏朵粬妯″潡鐩戝惉锛屽鍙戦�佷紒涓氬井淇¢�氱煡锛�
eventPublisher.publishEvent(new SocialLoginEvent(
@@ -428,4 +458,4 @@
userService.updateUserPassword(userByMobile.getId(), reqVO.getPassword());
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3