feat(auth,prompt-rule): add password change with session revocation and scope prompt rules by brand
Add self-service password change that re-hashes the credential and bumps a per-user session version so all existing access/refresh tokens are rejected. Session version is tracked in Redis with an in-memory fallback and enforced in middleware and refresh. Scope prompt rules and rule groups to a brand: new brand_id column (migrated to a "未归属" fallback brand for existing rows), brand-filtered queries/indexes, and brand-aware admin-web tabs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,9 +16,11 @@ import PromptRuleModal from '@/components/PromptRuleModal.vue'
|
||||
import { promptRulesApi } from '@/lib/api'
|
||||
import { formatDateTime } from '@/lib/display'
|
||||
import { formatError } from '@/lib/errors'
|
||||
import { useCompanyStore } from '@/stores/company'
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useI18n()
|
||||
const companyStore = useCompanyStore()
|
||||
|
||||
const selectedGroupId = ref<number | 'all' | 'ungrouped'>('all')
|
||||
const ruleModalOpen = ref(false)
|
||||
@@ -30,7 +32,8 @@ const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
|
||||
const groupsQuery = useQuery({
|
||||
queryKey: ['promptRules', 'groups'],
|
||||
queryKey: computed(() => ['promptRules', 'groups', companyStore.currentBrandId]),
|
||||
enabled: computed(() => Boolean(companyStore.currentBrandId)),
|
||||
queryFn: () => promptRulesApi.listGroups(),
|
||||
})
|
||||
|
||||
@@ -48,7 +51,8 @@ const ruleListParams = computed(() => {
|
||||
})
|
||||
|
||||
const rulesQuery = useQuery({
|
||||
queryKey: computed(() => ['promptRules', 'list', ruleListParams.value]),
|
||||
queryKey: computed(() => ['promptRules', 'list', companyStore.currentBrandId, ruleListParams.value]),
|
||||
enabled: computed(() => Boolean(companyStore.currentBrandId)),
|
||||
queryFn: () => promptRulesApi.list(ruleListParams.value),
|
||||
})
|
||||
|
||||
@@ -169,6 +173,17 @@ function handleTableChange(nextPage: number, nextPageSize: number): void {
|
||||
watch(selectedGroupId, () => {
|
||||
page.value = 1
|
||||
})
|
||||
|
||||
watch(
|
||||
() => companyStore.currentBrandId,
|
||||
() => {
|
||||
selectedGroupId.value = 'all'
|
||||
editingRule.value = null
|
||||
ruleModalOpen.value = false
|
||||
groupModalOpen.value = false
|
||||
page.value = 1
|
||||
},
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user