feat(auth,prompt-rule): add password change with session revocation and scope prompt rules by brand
Frontend CI / Frontend (push) Successful in 3m8s
Backend CI / Backend (push) Successful in 14m48s

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:
2026-05-20 18:09:53 +08:00
parent 9f9e4f8e19
commit e045e00fbf
41 changed files with 1135 additions and 167 deletions
@@ -267,7 +267,7 @@ func (s *PromptRuleGenerationService) enqueuePromptRuleGeneration(ctx context.Co
return nil, response.ErrBadRequest(40033, "brand_context_required", "current brand is required")
}
rule, err := s.loadPromptRule(ctx, input.TenantID, input.PromptRuleID)
rule, err := s.loadPromptRule(ctx, input.TenantID, *input.BrandID, input.PromptRuleID)
if err != nil {
return nil, err
}
@@ -476,13 +476,13 @@ func (s *PromptRuleGenerationService) enqueuePromptRuleGeneration(ctx context.Co
return &GenerateFromRuleResponse{ArticleID: articleID, TaskID: taskID}, nil
}
func (s *PromptRuleGenerationService) loadPromptRule(ctx context.Context, tenantID, promptRuleID int64) (*promptRuleGenerationRecord, error) {
func (s *PromptRuleGenerationService) loadPromptRule(ctx context.Context, tenantID, brandID, promptRuleID int64) (*promptRuleGenerationRecord, error) {
record := &promptRuleGenerationRecord{}
err := s.pool.QueryRow(ctx, `
SELECT id, name, prompt_content, scene, default_tone, default_word_count, status
FROM prompt_rules
WHERE id = $1 AND tenant_id = $2 AND deleted_at IS NULL
`, promptRuleID, tenantID).Scan(
WHERE id = $1 AND tenant_id = $2 AND brand_id = $3 AND deleted_at IS NULL
`, promptRuleID, tenantID, brandID).Scan(
&record.ID,
&record.Name,
&record.PromptContent,