fix(mount): load username from mount when testing without it
This commit is contained in:
parent
099f7c0628
commit
44c3f830f5
|
|
@ -151,12 +151,13 @@ export const mountService = {
|
|||
} catch (e) {
|
||||
return { ok: false, message: e instanceof Error ? e.message : "地址不合法" };
|
||||
}
|
||||
// 编辑时密码留空:复用已存密文测连,避免每次重填
|
||||
// 编辑时密码留空:复用已存密文测连,避免每次重填;用户名缺省也从挂载读取
|
||||
let password = input.password;
|
||||
let username = input.username;
|
||||
let usedStored = false;
|
||||
if (!password && input.mountId && userId) {
|
||||
if (input.mountId && userId) {
|
||||
const existing = await mountDao.getByIdForUser(input.mountId, userId);
|
||||
if (existing?.secretEnc) {
|
||||
if (!password && existing?.secretEnc) {
|
||||
try {
|
||||
password = decryptSecret(existing.secretEnc);
|
||||
usedStored = true;
|
||||
|
|
@ -164,11 +165,12 @@ export const mountService = {
|
|||
// 密钥不一致等,退回空密码
|
||||
}
|
||||
}
|
||||
if (!username && existing?.username) username = existing.username;
|
||||
}
|
||||
try {
|
||||
const client = createWebdav({
|
||||
baseUrl: input.baseUrl,
|
||||
username: input.username,
|
||||
username,
|
||||
password,
|
||||
});
|
||||
const root = normalizeWebdavPath(input.rootPath || "/");
|
||||
|
|
|
|||
Loading…
Reference in New Issue