diff --git a/src/App.js b/src/App.js index ad9b7a9..b890cb0 100644 --- a/src/App.js +++ b/src/App.js @@ -12,8 +12,6 @@ const App = () => { <> - {/* */} - {/* */} diff --git a/src/Constant/identity.ts b/src/Constant/identity.ts deleted file mode 100644 index 7dd4790..0000000 --- a/src/Constant/identity.ts +++ /dev/null @@ -1 +0,0 @@ -export const OAUTH_URL = 'https://test.provenance.io/login/oauth/authorize'; \ No newline at end of file diff --git a/src/actions/identity-actions.ts b/src/actions/identity-actions.ts deleted file mode 100644 index fcada20..0000000 --- a/src/actions/identity-actions.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { createAction } from "redux-actions"; -import { P8E_URL } from "Constant/http"; -import { addError } from "./error-actions"; -import { ajaxGet } from "./xhr-actions"; - -const BASE_URL = `${P8E_URL}/external/api/v1/provenance/oauth`; - -export const LOGOUT = 'IDENTITY::LOGOUT'; -export const OAUTH_LOGIN = 'IDENTITY::OAUTH_LOGIN'; -export const OAUTH_TOKEN_EXCHANGE = 'IDENTITY::OAUTH_TOKEN_EXCHANGE'; -export const LOGIN = 'IDENTITY::LOGIN'; - -export const logout = () => async dispatch => dispatch(createAction(LOGOUT)()); - -export const oauthLogin = (redirectUrl: string) => async dispatch => ajaxGet(OAUTH_LOGIN, dispatch, `${BASE_URL}?redirectUrl=${redirectUrl}`) - .then(({ url }) => window.location.href = url); - -export const oauthTokenExchange = (code, state) => async dispatch => ajaxGet(OAUTH_TOKEN_EXCHANGE, dispatch, `${BASE_URL}/callback`, { params: { code, state } }) - .then(({ access_token, cookie_name }) => dispatch(login(access_token))) - .catch((err) => { - err.data.errors.forEach(error => dispatch(addError(error))) - return Promise.reject(err); - }); - -export const login = (jwt: string) => async dispatch => dispatch(createAction(LOGIN)(jwt)); \ No newline at end of file diff --git a/src/components/Layout/Menu/MenuContainer.tsx b/src/components/Layout/Menu/MenuContainer.tsx index e92d7db..9cbe673 100644 --- a/src/components/Layout/Menu/MenuContainer.tsx +++ b/src/components/Layout/Menu/MenuContainer.tsx @@ -1,8 +1,6 @@ import React from 'react'; -import { useDispatch } from 'react-redux'; import { withRouter } from 'react-router-dom'; -import { logout } from 'actions/identity-actions'; -import { Menu, MenuLink, MenuLinkText, MenuListItem } from './index'; +import { Menu, MenuLink } from './index'; import { Location } from 'history'; type MenuContainerProps = { @@ -10,11 +8,6 @@ type MenuContainerProps = { } const MenuContainer = ({ location }) => { - const dispatch = useDispatch(); - const handleLogout = () => { - dispatch(logout()); - }; - return (
    @@ -22,9 +15,6 @@ const MenuContainer = ({ location }) => { - - Logout -
); diff --git a/src/components/Login/LoginContainer.tsx b/src/components/Login/LoginContainer.tsx deleted file mode 100644 index a7e329b..0000000 --- a/src/components/Login/LoginContainer.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import React from 'react'; -import { useDispatch } from 'react-redux'; -import PageLayout from 'components/Layout/PageLayout'; -import styled from 'styled-components'; -import { oauthLogin } from 'actions/identity-actions'; -import { IconButton } from 'components/Button'; -import { currentLocation } from 'helpers/general'; -import { Sprite } from 'components/Sprite'; -import { useDeepLink } from 'hooks'; - -const Container = styled.div` - display: flex; - flex-grow: 1; - align-items: center; - justify-content: center; -`; - -export const LoginContainer = () => { - const dispatch = useDispatch(); - const { location, setDeepLinkLocation } = useDeepLink(); - - const handleLogin = () => { - setDeepLinkLocation(location.pathname); - dispatch(oauthLogin(currentLocation())) - }; - - return - - - Login with Provenance - - - -}; \ No newline at end of file diff --git a/src/components/Login/index.ts b/src/components/Login/index.ts deleted file mode 100644 index c0aa29e..0000000 --- a/src/components/Login/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { LoginContainer } from './LoginContainer'; \ No newline at end of file diff --git a/src/components/OAuth/OAuthCallback.tsx b/src/components/OAuth/OAuthCallback.tsx deleted file mode 100644 index 4aed68d..0000000 --- a/src/components/OAuth/OAuthCallback.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React, { useEffect } from 'react'; -import { withRouter } from 'react-router-dom'; -import { useDispatch } from 'react-redux'; -import { parseParams } from 'helpers/params'; -import { Loader } from 'components/Loader/Loader'; -import { oauthTokenExchange } from 'actions/identity-actions'; - -const OAuthCallback = ({ location, history }) => { - const { code, state } = parseParams(location.search); - const dispatch = useDispatch(); - - useEffect(() => { - dispatch(oauthTokenExchange(code, state)).catch(() => history.push('/')) - }, [code, state, dispatch, history]) - - return -} - -export default withRouter(OAuthCallback); \ No newline at end of file diff --git a/src/components/OAuth/index.ts b/src/components/OAuth/index.ts deleted file mode 100644 index 1b9f006..0000000 --- a/src/components/OAuth/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as OAuthCallback } from './OAuthCallback'; \ No newline at end of file