persistence: DeleteTenant чистит и tenant_ak (отзыв access key)

This commit is contained in:
Repinoid
2026-10-11 08:27:22 +03:00
parent 09fe0f7e66
commit 9e0ad2c0a4
2 changed files with 10 additions and 3 deletions
+8 -1
View File
@@ -610,7 +610,9 @@ func LoadTenantByAccessKey(accessKey string) ([]byte, bool) {
} }
// DeleteTenant — удаляет тенанта из Redis асинхронно. // DeleteTenant — удаляет тенанта из Redis асинхронно.
func DeleteTenant(id string) { // Удаляет из ОБОИХ индексов: ssq:tenants (по id) и ssq:tenant_ak (по accessKey),
// иначе LoadTenantByAccessKey вернёт удалённого тенанта и отзыв ключей не сработает.
func DeleteTenant(id, accessKey string) {
if Client == nil { if Client == nil {
return return
} }
@@ -624,6 +626,11 @@ func DeleteTenant(id string) {
if err := Client.HDel(ctx, redisHashTenants, id).Err(); err != nil { if err := Client.HDel(ctx, redisHashTenants, id).Err(); err != nil {
log.Errorf("persistence: HDel tenant %q: %v", id, err) log.Errorf("persistence: HDel tenant %q: %v", id, err)
} }
if accessKey != "" {
if err := Client.HDel(ctx, redisHashTenantAK, accessKey).Err(); err != nil {
log.Errorf("persistence: HDel tenant_ak %q: %v", accessKey, err)
}
}
}) })
} }
+2 -2
View File
@@ -183,8 +183,8 @@ func (s *TenantStore) Delete(id string) bool {
} }
s.mu.Unlock() s.mu.Unlock()
// Удаляем из Redis асинхронно // Удаляем из Redis асинхронно (оба индекса: по id и по accessKey)
persistence.DeleteTenant(id) persistence.DeleteTenant(id, t.AccessKey)
return true return true
} }