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:
@@ -9,6 +9,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import KnowledgeGroupSelect from '@/components/KnowledgeGroupSelect.vue'
|
||||
import { promptRulesApi } from '@/lib/api'
|
||||
import { formatError } from '@/lib/errors'
|
||||
import { useCompanyStore } from '@/stores/company'
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean
|
||||
@@ -22,6 +23,7 @@ const emit = defineEmits<{
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useI18n()
|
||||
const companyStore = useCompanyStore()
|
||||
|
||||
const form = reactive({
|
||||
name: '',
|
||||
@@ -34,7 +36,8 @@ const form = reactive({
|
||||
})
|
||||
|
||||
const groupsQuery = useQuery({
|
||||
queryKey: ['promptRules', 'groups'],
|
||||
queryKey: computed(() => ['promptRules', 'groups', companyStore.currentBrandId]),
|
||||
enabled: computed(() => props.open && Boolean(companyStore.currentBrandId)),
|
||||
queryFn: () => promptRulesApi.listGroups(),
|
||||
})
|
||||
|
||||
@@ -56,6 +59,15 @@ watch(
|
||||
},
|
||||
)
|
||||
|
||||
watch(
|
||||
() => companyStore.currentBrandId,
|
||||
() => {
|
||||
if (props.open) {
|
||||
emit('update:open', false)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: () =>
|
||||
promptRulesApi.create({
|
||||
|
||||
Reference in New Issue
Block a user