Skip to content

Commit

Permalink
feat: route cxl-sso redirect to WordPress OAuth endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelkmpt committed Oct 15, 2024
1 parent a11b451 commit e794e24
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.

This file was deleted.

16 changes: 16 additions & 0 deletions packages/ui-react/src/pages/RedirectToExternal/RedirectToSSO.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { useEffect } from 'react';
import { useOAuth } from '@jwp/ott-hooks-react/src/useOAuth';
import { useNavigate } from 'react-router-dom';

const RedirectToSSO: React.FC = () => {
const navigate = useNavigate();
const { login: oAuthLogin } = useOAuth();

useEffect(() => {
oAuthLogin();
}, [navigate, oAuthLogin]);

return null; // Render nothing
};

export default RedirectToSSO;
4 changes: 2 additions & 2 deletions platforms/web/src/containers/AppRoutes/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Home from '@jwp/ott-ui-react/src/pages/Home/Home';
import Search from '@jwp/ott-ui-react/src/pages/Search/Search';
import User from '@jwp/ott-ui-react/src/pages/User/User';
import LegacySeries from '@jwp/ott-ui-react/src/pages/LegacySeries/LegacySeries';
import RedirectToSSO from '@jwp/ott-ui-react/src/pages/RedirectToExternal/RedirectToSSO';
import MediaScreenRouter from '@jwp/ott-ui-react/src/pages/ScreenRouting/MediaScreenRouter';
import PlaylistScreenRouter from '@jwp/ott-ui-react/src/pages/ScreenRouting/PlaylistScreenRouter';
import Layout from '@jwp/ott-ui-react/src/containers/Layout/Layout';
Expand All @@ -35,7 +36,6 @@ import {
} from '@jwp/ott-common/src/paths';

import useNotifications from '#src/hooks/useNotifications';
import RedirectToExternal from '@jwp/ott-ui-react/src/pages/RedirectToExternal/RedirectToExternal';

export default function AppRoutes() {
const location = useLocation();
Expand Down Expand Up @@ -93,7 +93,7 @@ export default function AppRoutes() {
element={<ErrorPage title={t('notfound_error_heading', 'Not found')} message={t('notfound_error_description', "This page doesn't exist.")} />}
/>
</Route>
<Route path="/cxl-sso" element={<RedirectToExternal />} />
<Route path="/cxl-sso" element={<RedirectToSSO />} />
</Routes>
);
}

0 comments on commit e794e24

Please sign in to comment.