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