fix: evita logout al cambiar de tenant (race condition refresh token)
This commit is contained in:
@@ -7,6 +7,7 @@ import { Header } from '@/components/layouts/header';
|
||||
import { Card, CardContent, CardHeader, CardTitle, Button, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '@horux/shared-ui';
|
||||
import { getMyTenants, addMyTenant, type MyTenantDetailed } from '@/lib/api/tenants';
|
||||
import { switchTenant } from '@/lib/api/auth';
|
||||
import { cancelAllApiRequests } from '@/lib/api/client';
|
||||
import { useAuthStore } from '@/stores/auth-store';
|
||||
import { formatCurrency } from '@/lib/utils';
|
||||
import { Building2, Plus, Crown, ArrowRight, Loader2, AlertCircle, CheckCircle2 } from 'lucide-react';
|
||||
@@ -61,6 +62,9 @@ export default function MisEmpresasPage() {
|
||||
router.push('/dashboard');
|
||||
return;
|
||||
}
|
||||
// Cancela requests pendientes para evitar que intenten refrescar con el
|
||||
// token que switchTenant va a invalidar.
|
||||
cancelAllApiRequests();
|
||||
try {
|
||||
const res = await switchTenant(tenantId);
|
||||
setTokens(res.accessToken, res.refreshToken);
|
||||
|
||||
Reference in New Issue
Block a user