removed old beta

This commit is contained in:
jackiettran
2025-09-19 22:33:44 -04:00
parent 649289bf90
commit 6199609a4d
5 changed files with 524 additions and 33 deletions

View File

@@ -1,7 +1,6 @@
import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { AuthProvider } from './contexts/AuthContext';
import BetaPasswordProtection from './components/BetaPasswordProtection';
import Navbar from './components/Navbar';
import Footer from './components/Footer';
import Home from './pages/Home';
@@ -28,13 +27,12 @@ import './App.css';
function App() {
return (
<BetaPasswordProtection>
<AuthProvider>
<Router>
<div className="d-flex flex-column min-vh-100">
<Navbar />
<main className="flex-grow-1">
<Routes>
<AuthProvider>
<Router>
<div className="d-flex flex-column min-vh-100">
<Navbar />
<main className="flex-grow-1">
<Routes>
<Route path="/" element={<Home />} />
<Route path="/login" element={<Login />} />
<Route path="/register" element={<Register />} />
@@ -137,7 +135,6 @@ function App() {
</div>
</Router>
</AuthProvider>
</BetaPasswordProtection>
);
}

View File

@@ -13,7 +13,10 @@ let failedQueue: Array<{
config: AxiosRequestConfig;
}> = [];
const processQueue = (error: AxiosError | null, token: string | null = null) => {
const processQueue = (
error: AxiosError | null,
token: string | null = null
) => {
failedQueue.forEach((prom) => {
if (error) {
prom.reject(error);
@@ -52,13 +55,13 @@ export const resetCSRFToken = () => {
// Check if authentication cookie exists
export const hasAuthCookie = (): boolean => {
return document.cookie
.split('; ')
.some(cookie => cookie.startsWith('accessToken='));
.split("; ")
.some((cookie) => cookie.startsWith("accessToken="));
};
// Check if user has any auth indicators
export const hasAuthIndicators = (): boolean => {
return hasAuthCookie() || !!localStorage.getItem('token');
return hasAuthCookie();
};
api.interceptors.request.use(async (config) => {
@@ -68,7 +71,9 @@ api.interceptors.request.use(async (config) => {
// If we don't have a CSRF token yet, try to fetch it
if (!csrfToken) {
// Skip fetching for auth endpoints to avoid circular dependency
const isAuthEndpoint = config.url?.includes("/auth/") && !config.url?.includes("/auth/refresh");
const isAuthEndpoint =
config.url?.includes("/auth/") &&
!config.url?.includes("/auth/refresh");
if (!isAuthEndpoint) {
await fetchCSRFToken();
}
@@ -85,12 +90,18 @@ api.interceptors.request.use(async (config) => {
api.interceptors.response.use(
(response) => response,
async (error: AxiosError) => {
const originalRequest = error.config as AxiosRequestConfig & { _retry?: boolean, _csrfRetry?: boolean };
const originalRequest = error.config as AxiosRequestConfig & {
_retry?: boolean;
_csrfRetry?: boolean;
};
// Handle CSRF token errors
if (error.response?.status === 403) {
const errorData = error.response?.data as any;
if (errorData?.code === "CSRF_TOKEN_MISMATCH" && !originalRequest._csrfRetry) {
if (
errorData?.code === "CSRF_TOKEN_MISMATCH" &&
!originalRequest._csrfRetry
) {
originalRequest._csrfRetry = true;
// Try to fetch a new CSRF token and retry