保存邮件通知权限回归修复前检查点
This commit is contained in:
1 parent
5ed080e171
commit
bbd5376a66
4 files changed
+160
No files matched your search
@@ -793,6 +793,12 @@ export function useDashboard() {
|
||||
function openSettings() {
|
||||
settingsError.value = "";
|
||||
dnsTestError.value = "";
|
||||
if (!canManageSystemSettings.value) {
|
||||
settingsForm.value = normalizeSettings(null);
|
||||
showSettings.value = false;
|
||||
settingsError.value = "只有超级管理员可以配置邮件通知和系统设置";
|
||||
return;
|
||||
}
|
||||
settingsForm.value = normalizeSettings(settings.value);
|
||||
showSettings.value = true;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,26 @@ import test from "node:test";
|
||||
import { useDashboard } from "./Dashboard.js";
|
||||
import { deferred, mountComposable } from "../../test-support/mount.js";
|
||||
|
||||
for (const role of ["admin", "user"]) {
|
||||
test(`邮件配置仅超管可用,禁止绕过入口提交:${role}`, async (t) => {
|
||||
const writes = [];
|
||||
const { state } = await mountComposable(t, useDashboard, async (path, init = {}) => {
|
||||
if (init.method) writes.push({ path, ...init });
|
||||
if (path.endsWith("/auth/session")) return Response.json({ role });
|
||||
return Response.json({ items: [] });
|
||||
});
|
||||
state.settingsForm.value.notification.smtp_password = "stale-unsaved-secret";
|
||||
state.showSettings.value = true;
|
||||
state.openSettings();
|
||||
assert.equal(state.showSettings.value, false);
|
||||
assert.equal(state.settingsForm.value.notification.smtp_password, "");
|
||||
assert.match(state.settingsError.value, /只有超级管理员/);
|
||||
await state.saveSettings();
|
||||
assert.deepEqual(writes, []);
|
||||
assert.match(state.settingsError.value, /只有超级管理员/);
|
||||
});
|
||||
}
|
||||
|
||||
for (const role of ["admin", "user", "super_admin"]) {
|
||||
test(`工作台按实时会话加载系统设置:${role}`, async (t) => {
|
||||
const requests = [];
|
||||
|
||||
Reference in new issue
Block a user