feat(admin): 顶部账号区支持修改自己的密码并失效旧会话

所有后台账号可在左上角修改本人密码:校验原密码、新密码至少 12 位,
成功后该账号所有既有会话立即失效需重新登录。会话校验新增密码哈希比对。
后端 615 项、前端 7 项测试全部通过。
This commit is contained in:
my_local_kimi_dev2
2026-11-19 10:48:51 +08:00
parent 2aa99abddd
commit 6dad85d6e4
6 changed files with 228 additions and 0 deletions
@@ -75,3 +75,21 @@ test('account management is only available to the admin account', async () => {
assert.match(source, /v-if="session\.account === 'admin' && openTabs\.includes\('accounts'\)"/, 'admin-only panel')
assert.match(source, /if \(id === 'accounts' && session\.account !== 'admin'\) return/, 'admin-only navigation guard')
})
test('every current account can change its own password from the account area', async () => {
const source = await readFile(new URL('../src/App.vue', import.meta.url), 'utf8')
const required = [
'admin-btn-change-password',
'admin-password-old',
'admin-password-new',
'admin-password-confirm',
'admin-password-cancel',
'admin-password-save',
]
for (const testId of required) {
assert.match(source, new RegExp(`data-testid=["']${testId}["']`), testId)
}
assert.match(source, /api\('\/auth\/password', \{ method: 'PUT'/, 'self-service password endpoint')
assert.match(source, /newPassword: passwordForm\.newPassword/, 'only sends password fields, not another account id')
assert.match(source, /loggedIn\.value = false/, 'returns to login after changing password')
})