refactor(系统设置): LDAP登录逻辑
This commit is contained in:
parent
41e7f8bffe
commit
493f678643
|
@ -107,14 +107,22 @@ public class LdapService {
|
|||
} else {
|
||||
// 更新
|
||||
u.setName(name);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
u.setPhone(phone);
|
||||
}
|
||||
if (StringUtils.isNotBlank(email)) {
|
||||
u.setEmail(email);
|
||||
}
|
||||
userLoginService.updateUser(u);
|
||||
}
|
||||
|
||||
// 执行 LocalRealm 中 LDAP 登录逻辑
|
||||
LoginRequest loginRequest = new LoginRequest();
|
||||
if (u != null) {
|
||||
// 根据id或email查找到了用户,后续使用此用户id登录
|
||||
loginRequest.setUsername(u.getId());
|
||||
} else {
|
||||
loginRequest.setUsername(userId);
|
||||
}
|
||||
loginRequest.setAuthenticate(UserSource.LDAP.name());
|
||||
|
||||
Optional<SessionUser> sessionUser = userLoginService.login(loginRequest, session, locale);
|
||||
|
|
|
@ -65,7 +65,8 @@ public class UserLoginService {
|
|||
}
|
||||
|
||||
private UserDTO loginLdapMode(String userId) {
|
||||
UserDTO loginUser = getLoginUser(userId, Collections.singletonList(UserSource.LDAP.name()));
|
||||
// LDAP验证通过之后,如果用户存在且用户类型是LDAP或LOCAL,返回用户
|
||||
UserDTO loginUser = getLoginUser(userId, Arrays.asList(UserSource.LDAP.name(), UserSource.LOCAL.name()));
|
||||
if (loginUser == null) {
|
||||
MSException.throwException(Translator.get("user_not_found_or_not_unique"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue