From 9e0ad2c0a4ac35747ebf08c86f07dd4a50738414 Mon Sep 17 00:00:00 2001 From: Repinoid Date: Sun, 11 Oct 2026 08:27:22 +0300 Subject: [PATCH] =?UTF-8?q?persistence:=20DeleteTenant=20=D1=87=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=B8=D1=82=20=D0=B8=20tenant=5Fak=20(=D0=BE=D1=82?= =?UTF-8?q?=D0=B7=D1=8B=D0=B2=20access=20key)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/persistence/redis.go | 9 ++++++++- app/tenant/tenant_store.go | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/persistence/redis.go b/app/persistence/redis.go index 7bbaef4..5e120c9 100644 --- a/app/persistence/redis.go +++ b/app/persistence/redis.go @@ -610,7 +610,9 @@ func LoadTenantByAccessKey(accessKey string) ([]byte, bool) { } // DeleteTenant — удаляет тенанта из Redis асинхронно. -func DeleteTenant(id string) { +// Удаляет из ОБОИХ индексов: ssq:tenants (по id) и ssq:tenant_ak (по accessKey), +// иначе LoadTenantByAccessKey вернёт удалённого тенанта и отзыв ключей не сработает. +func DeleteTenant(id, accessKey string) { if Client == nil { return } @@ -624,6 +626,11 @@ func DeleteTenant(id string) { if err := Client.HDel(ctx, redisHashTenants, id).Err(); err != nil { 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) + } + } }) } diff --git a/app/tenant/tenant_store.go b/app/tenant/tenant_store.go index 56db184..9f72ea0 100644 --- a/app/tenant/tenant_store.go +++ b/app/tenant/tenant_store.go @@ -183,8 +183,8 @@ func (s *TenantStore) Delete(id string) bool { } s.mu.Unlock() - // Удаляем из Redis асинхронно - persistence.DeleteTenant(id) + // Удаляем из Redis асинхронно (оба индекса: по id и по accessKey) + persistence.DeleteTenant(id, t.AccessKey) return true }