|
@@ -570,10 +570,21 @@ public class LoginController {
|
|
|
@ApiLog(value = "钉钉授权登录", type = LogTypeEnum.LOGIN)
|
|
@ApiLog(value = "钉钉授权登录", type = LogTypeEnum.LOGIN)
|
|
|
@ApiOperation("钉钉授权登录")
|
|
@ApiOperation("钉钉授权登录")
|
|
|
public ResponseEntity dingTalkAuthCodeLogin(@RequestBody LoginForm loginForm) {
|
|
public ResponseEntity dingTalkAuthCodeLogin(@RequestBody LoginForm loginForm) {
|
|
|
|
|
+ log.info("===== 钉钉免登开始 =====");
|
|
|
|
|
+ log.info("请求参数: tenantId={}, authCode={}", loginForm.getTenantId(),
|
|
|
|
|
+ loginForm.getAuthCode() != null ? loginForm.getAuthCode().substring(0, Math.min(10, loginForm.getAuthCode().length())) + "..." : "null");
|
|
|
|
|
+
|
|
|
String tenantId = StringUtils.defaultIfBlank(loginForm.getTenantId(), "10009");
|
|
String tenantId = StringUtils.defaultIfBlank(loginForm.getTenantId(), "10009");
|
|
|
|
|
+ log.info("步骤1: 通过authCode获取钉钉用户信息...");
|
|
|
|
|
+
|
|
|
DingTalkAuthService.DingTalkUser dingTalkUser = dingTalkAuthService.getUserByAuthCode(tenantId, loginForm.getAuthCode());
|
|
DingTalkAuthService.DingTalkUser dingTalkUser = dingTalkAuthService.getUserByAuthCode(tenantId, loginForm.getAuthCode());
|
|
|
|
|
+ log.info("步骤1成功: 获取到钉钉用户 userId={}, unionId={}", dingTalkUser.getUserId(), dingTalkUser.getUnionId());
|
|
|
|
|
+
|
|
|
|
|
+ log.info("步骤2: 查询系统用户绑定关系...");
|
|
|
UserDTO user = userApi.getByDdIdAndTenantId(dingTalkUser.getUserId(), tenantId);
|
|
UserDTO user = userApi.getByDdIdAndTenantId(dingTalkUser.getUserId(), tenantId);
|
|
|
|
|
+
|
|
|
if (user == null) {
|
|
if (user == null) {
|
|
|
|
|
+ log.warn("用户未绑定,需要绑定账号: ddId={}, tenantId={}", dingTalkUser.getUserId(), tenantId);
|
|
|
String bindKey = dingTalkAuthService.createBindKey(tenantId, dingTalkUser.getUserId());
|
|
String bindKey = dingTalkAuthService.createBindKey(tenantId, dingTalkUser.getUserId());
|
|
|
return ResponseUtil.newInstance()
|
|
return ResponseUtil.newInstance()
|
|
|
.add("bindRequired", true)
|
|
.add("bindRequired", true)
|
|
@@ -581,6 +592,8 @@ public class LoginController {
|
|
|
.add("tenantId", tenantId)
|
|
.add("tenantId", tenantId)
|
|
|
.ok("DingTalk account is not bound");
|
|
.ok("DingTalk account is not bound");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ log.info("步骤2成功: 找到绑定用户 loginName={}, name={}", user.getLoginName(), user.getName());
|
|
|
|
|
|
|
|
ResponseUtil responseUtil = new ResponseUtil();
|
|
ResponseUtil responseUtil = new ResponseUtil();
|
|
|
String loginUserName = user.getLoginName();
|
|
String loginUserName = user.getLoginName();
|