| 62 | superuserCheckStarted.current = true; |
| 63 | |
| 64 | async function checkSuperuser() { |
| 65 | try { |
| 66 | const response = await API.fetchSuperUser(); |
| 67 | if (response && response.superuser_exists === false) { |
| 68 | setSuperuserExists(false); |
| 69 | } |
| 70 | } catch (error) { |
| 71 | console.error('Error checking superuser status:', error); |
| 72 | // If authentication error, redirect to login |
| 73 | if (error.status === 401) { |
| 74 | localStorage.removeItem('token'); |
| 75 | localStorage.removeItem('refreshToken'); |
| 76 | window.location.href = '/login'; |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | checkSuperuser(); |
| 81 | }, [setSuperuserExists]); |
| 82 | |