fix(mount): mark test connection using stored password
This commit is contained in:
parent
96b3d8679b
commit
099f7c0628
|
|
@ -153,9 +153,17 @@ export const mountService = {
|
||||||
}
|
}
|
||||||
// 编辑时密码留空:复用已存密文测连,避免每次重填
|
// 编辑时密码留空:复用已存密文测连,避免每次重填
|
||||||
let password = input.password;
|
let password = input.password;
|
||||||
|
let usedStored = false;
|
||||||
if (!password && input.mountId && userId) {
|
if (!password && input.mountId && userId) {
|
||||||
const existing = await mountDao.getByIdForUser(input.mountId, userId);
|
const existing = await mountDao.getByIdForUser(input.mountId, userId);
|
||||||
if (existing?.secretEnc) password = decryptSecret(existing.secretEnc);
|
if (existing?.secretEnc) {
|
||||||
|
try {
|
||||||
|
password = decryptSecret(existing.secretEnc);
|
||||||
|
usedStored = true;
|
||||||
|
} catch {
|
||||||
|
// 密钥不一致等,退回空密码
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const client = createWebdav({
|
const client = createWebdav({
|
||||||
|
|
@ -166,19 +174,26 @@ export const mountService = {
|
||||||
const root = normalizeWebdavPath(input.rootPath || "/");
|
const root = normalizeWebdavPath(input.rootPath || "/");
|
||||||
try {
|
try {
|
||||||
await listDirectory(client, root);
|
await listDirectory(client, root);
|
||||||
return { ok: true, message: "连接成功" };
|
return {
|
||||||
|
ok: true,
|
||||||
|
message: usedStored ? "连接成功(使用已保存的密码)" : "连接成功",
|
||||||
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// 根路径失败:再探 / 仅用于补充提示,不以 / 的成败作为结论
|
|
||||||
// (部分 NAS 禁止列 /,或 / 与共享根权限不同)
|
|
||||||
try {
|
try {
|
||||||
await listDirectory(client, "/");
|
await listDirectory(client, "/");
|
||||||
} catch {
|
} catch {
|
||||||
// 忽略
|
// 忽略根探测
|
||||||
}
|
}
|
||||||
return { ok: false, message: describeWebdavError(e, root) };
|
const base = describeWebdavError(e);
|
||||||
|
return {
|
||||||
|
ok: false,
|
||||||
|
message: usedStored
|
||||||
|
? `${base}(使用已保存的密码)`
|
||||||
|
: base,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { ok: false, message: describeWebdavError(e, input.rootPath || "/") };
|
return { ok: false, message: describeWebdavError(e) };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue