refactor(LDAP): 登录时更新ldap用户信息
This commit is contained in:
parent
4f0751788f
commit
2786714482
|
@ -49,11 +49,13 @@ public class LdapController {
|
||||||
|
|
||||||
// userId 或 email 有一个相同即为存在本地用户
|
// userId 或 email 有一个相同即为存在本地用户
|
||||||
User u = userService.selectUser(userId, email);
|
User u = userService.selectUser(userId, email);
|
||||||
|
String name = ldapService.getMappingAttr("name", dirContext);
|
||||||
|
String phone = ldapService.getNotRequiredMappingAttr("phone", dirContext);
|
||||||
if (u == null) {
|
if (u == null) {
|
||||||
|
|
||||||
// 新建用户 获取LDAP映射属性
|
// 新建用户 获取LDAP映射属性
|
||||||
String name = ldapService.getMappingAttr("name", dirContext);
|
// String name = ldapService.getMappingAttr("name", dirContext);
|
||||||
String phone = ldapService.getNotRequiredMappingAttr("phone", dirContext);
|
// String phone = ldapService.getNotRequiredMappingAttr("phone", dirContext);
|
||||||
|
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setId(userId);
|
user.setId(userId);
|
||||||
|
@ -66,6 +68,12 @@ public class LdapController {
|
||||||
|
|
||||||
user.setSource(UserSource.LDAP.name());
|
user.setSource(UserSource.LDAP.name());
|
||||||
userService.addLdapUser(user);
|
userService.addLdapUser(user);
|
||||||
|
} else {
|
||||||
|
// 更新
|
||||||
|
u.setName(name);
|
||||||
|
u.setPhone(phone);
|
||||||
|
u.setEmail(email);
|
||||||
|
userService.updateUser(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行 LocalRealm 中 LDAP 登录逻辑
|
// 执行 LocalRealm 中 LDAP 登录逻辑
|
||||||
|
|
Loading…
Reference in New Issue