Commit f289678f by CaIon

fix: add dynamic route for custom OAuth provider callbacks (#2911)

Custom OAuth providers redirect to /oauth/{slug} after authorization,
but only hardcoded provider routes (github, discord, oidc, linuxdo)
existed in the frontend router, causing a 404 for custom providers.
parent d45cd9af
......@@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React, { lazy, Suspense, useContext, useMemo } from 'react';
import { Route, Routes, useLocation } from 'react-router-dom';
import { Route, Routes, useLocation, useParams } from 'react-router-dom';
import Loading from './components/common/ui/Loading';
import User from './pages/User';
import { AuthRedirect, PrivateRoute, AdminRoute } from './helpers';
......@@ -56,6 +56,11 @@ const About = lazy(() => import('./pages/About'));
const UserAgreement = lazy(() => import('./pages/UserAgreement'));
const PrivacyPolicy = lazy(() => import('./pages/PrivacyPolicy'));
function DynamicOAuth2Callback() {
const { provider } = useParams();
return <OAuth2Callback type={provider} />;
}
function App() {
const location = useLocation();
const [statusState] = useContext(StatusContext);
......@@ -235,6 +240,14 @@ function App() {
}
/>
<Route
path='/oauth/:provider'
element={
<Suspense fallback={<Loading></Loading>} key={location.pathname}>
<DynamicOAuth2Callback />
</Suspense>
}
/>
<Route
path='/console/setting'
element={
<AdminRoute>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment