1. 调整 username 同步逻辑
2. 调整 eban 回调登录逻辑
This commit is contained in:
@@ -330,7 +330,7 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
|||||||
}
|
}
|
||||||
boolean inactive = isInactiveUser(user.getStatus());
|
boolean inactive = isInactiveUser(user.getStatus());
|
||||||
String username = resolveUsername(user);
|
String username = resolveUsername(user);
|
||||||
if (StrUtil.isBlank(username)) {
|
if (username == null) {
|
||||||
logSkip("人员", user.getId(), "缺少工号与登录账号,跳过同步");
|
logSkip("人员", user.getId(), "缺少工号与登录账号,跳过同步");
|
||||||
result.increaseSkipped();
|
result.increaseSkipped();
|
||||||
continue;
|
continue;
|
||||||
@@ -785,8 +785,8 @@ public class IWorkSyncProcessorImpl implements IWorkSyncProcessor {
|
|||||||
if (StrUtil.isNotBlank(user.getLoginid())) {
|
if (StrUtil.isNotBlank(user.getLoginid())) {
|
||||||
return user.getLoginid().trim();
|
return user.getLoginid().trim();
|
||||||
}
|
}
|
||||||
String workcode = resolveWorkcode(user);
|
// loginid 为空也继续同步,username 设为空字符串,不再回退工号
|
||||||
return StrUtil.isNotBlank(workcode) ? workcode : null;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -72,16 +72,21 @@ public class EbanOAuth2ServiceImpl implements EbanOAuth2Service {
|
|||||||
throw exception(AUTH_LOGIN_EBAN_TOKEN_INVALID);
|
throw exception(AUTH_LOGIN_EBAN_TOKEN_INVALID);
|
||||||
}
|
}
|
||||||
|
|
||||||
String workcode = StrUtil.trim(StrUtil.blankToDefault(userInfo.getLoginName(), userInfo.getUsername()));
|
String loginName = StrUtil.trim(userInfo.getLoginName());
|
||||||
if (StrUtil.isBlank(workcode)) {
|
AdminUserDO user = null;
|
||||||
log.error("E办OAuth2用户信息缺少工号(loginName),无法匹配账号: {}", JSONUtil.toJsonStr(userInfo));
|
if (StrUtil.isNotBlank(loginName)) {
|
||||||
throw exception(AUTH_LOGIN_EBAN_TOKEN_INVALID);
|
user = userService.getUserByUsername(loginName);
|
||||||
}
|
}
|
||||||
|
// 若未匹配到,再尝试用工号匹配(工号为空则不匹配)
|
||||||
AdminUserDO user = userService.getUserByWorkcode(workcode);
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
createLoginLog(null, workcode, LoginLogTypeEnum.LOGIN_SOCIAL, LoginResultEnum.BAD_CREDENTIALS);
|
String workcode = StrUtil.trim(StrUtil.blankToDefault(userInfo.getLoginName(), userInfo.getUsername()));
|
||||||
log.warn("E办OAuth2用户工号未在系统中找到对应账号: {}", workcode);
|
if (StrUtil.isNotBlank(workcode)) {
|
||||||
|
user = userService.getUserByWorkcode(workcode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (user == null) {
|
||||||
|
createLoginLog(null, loginName, LoginLogTypeEnum.LOGIN_SOCIAL, LoginResultEnum.BAD_CREDENTIALS);
|
||||||
|
log.warn("E办OAuth2 用户未找到匹配账号,loginName={} workcode={}", loginName, userInfo.getUsername());
|
||||||
throw exception(AUTH_LOGIN_EBAN_USER_NOT_SYNC);
|
throw exception(AUTH_LOGIN_EBAN_USER_NOT_SYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user