fix(auth): resolve concurrent session token refresh and state syncing issues to prevent frequent logouts

This commit is contained in:
Christian Vidal Wolf
2026-05-26 12:49:22 +02:00
parent 070da5ad0f
commit 8ea63f60c8
4 changed files with 90 additions and 43 deletions
+7 -9
View File
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import { Users, Search, CheckCircle, XCircle, Trash2, Shield, Loader2, AlertCircle, Clock } from 'lucide-react';
import { AuthSession } from '../lib/auth';
import { safeFetch } from '../lib/supabase';
interface User {
id: string;
@@ -27,11 +28,10 @@ export function UserManagementView({ session }: UserManagementViewProps) {
setError(null);
setWarning(null);
try {
const res = await fetch('/api/users-admin', {
const res = await safeFetch('/api/users-admin', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${session.access_token}`
'Content-Type': 'application/json'
},
body: JSON.stringify({ action: 'list' })
});
@@ -61,11 +61,10 @@ export function UserManagementView({ session }: UserManagementViewProps) {
setError(null);
setWarning(null);
try {
const res = await fetch('/api/users-admin', {
const res = await safeFetch('/api/users-admin', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${session.access_token}`
'Content-Type': 'application/json'
},
body: JSON.stringify({
action: 'validate',
@@ -104,11 +103,10 @@ export function UserManagementView({ session }: UserManagementViewProps) {
setError(null);
setDeleteConfirmUser(null);
try {
const res = await fetch('/api/users-admin', {
const res = await safeFetch('/api/users-admin', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${session.access_token}`
'Content-Type': 'application/json'
},
body: JSON.stringify({
action: 'delete',