fix: LDAP导入弹框OU列表和用户列表解析失败
根因: 后端 ou-list/user-list API 直接返回数组, 前端错误地从 res.ous/res.users 取值 - loadLdapOus: Array.isArray(res) 兼容处理 - loadLdapUsers: Array.isArray(res) 兼容处理 - LDAP用户显示字段: cn/uid/mail 替代 nickname/username/email
This commit is contained in:
1 parent
3a07432032
commit
9dda75efdb
1 file changed
+5
-5
@@ -960,7 +960,7 @@ function BatchImportModal({ onClose, onImported }: { onClose: () => void; onImpo
|
||||
setLdapLoading(true);
|
||||
try {
|
||||
const res = await ldapApi.listOus() as any;
|
||||
setLdapOus(res?.ous || []);
|
||||
setLdapOus(Array.isArray(res) ? res : (res?.ous || res?.data || []));
|
||||
} catch { toast('error', '加载 LDAP OU 失败'); }
|
||||
finally { setLdapLoading(false); }
|
||||
};
|
||||
@@ -969,7 +969,7 @@ function BatchImportModal({ onClose, onImported }: { onClose: () => void; onImpo
|
||||
setLdapLoading(true);
|
||||
try {
|
||||
const res = await ldapApi.listUsers({ base_dn: baseDn }) as any;
|
||||
setLdapUsers(res?.users || []);
|
||||
setLdapUsers(Array.isArray(res) ? res : (res?.users || res?.data || []));
|
||||
} catch { toast('error', '加载 LDAP 用户失败'); }
|
||||
finally { setLdapLoading(false); }
|
||||
};
|
||||
@@ -1201,9 +1201,9 @@ function BatchImportModal({ onClose, onImported }: { onClose: () => void; onImpo
|
||||
{ldapUsers.map(u => (
|
||||
<label key={u.dn} className="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-[var(--dg-bg-hover)] cursor-pointer">
|
||||
<input type="checkbox" checked={selectedLdapUsers.has(u.dn)} onChange={() => setSelectedLdapUsers(prev => { const n = new Set(prev); n.has(u.dn) ? n.delete(u.dn) : n.add(u.dn); return n; })} />
|
||||
<span className="text-sm font-medium">{u.nickname || u.username}</span>
|
||||
<span className="text-xs text-[var(--dg-text-muted)]">@{u.username}</span>
|
||||
{u.email && <span className="text-xs text-[var(--dg-text-muted)]">{u.email}</span>}
|
||||
<span className="text-sm font-medium">{u.cn || u.nickname || u.uid}</span>
|
||||
<span className="text-xs text-[var(--dg-text-muted)]">@{u.uid || u.username}</span>
|
||||
{u.mail && <span className="text-xs text-[var(--dg-text-muted)]">{u.mail}</span>}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user