persistence: DeleteTenant чистит и tenant_ak (отзыв access key)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user