From 9b0d4f810dbcdba6f1c219ede6a000d97110f2a2 Mon Sep 17 00:00:00 2001 From: "Erin E. Sullivan" Date: Fri, 18 Aug 2023 08:45:26 -0400 Subject: [PATCH] Updating `Login` component to `POST` to new `config.loginUrl`. --- package.json | 2 +- src/config/config.js | 15 +++---- src/modules/profile/components/Login/index.js | 43 ++++++++----------- 3 files changed, 24 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 450f2da05..1af35b159 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "eject": "react-scripts eject", "lint": "npx eslint src/**/*.js", "reinstall": "rm -rf node_modules && npm install", - "start": "REACT_APP_SPECTRUM_BASE_URL=${REACT_APP_SPECTRUM_BASE_URL:-https://search-staging.www.lib.umich.edu/spectrum} react-scripts start", + "start": "REACT_APP_SPECTRUM_BASE_URL=${REACT_APP_SPECTRUM_BASE_URL:-https://search-staging.www.lib.umich.edu/spectrum} REACT_APP_LOGIN_BASE_URL=${REACT_APP_LOGIN_BASE_URL:-https://search-staging.www.lib.umich.edu} react-scripts start", "test": "react-scripts test --env=jsdom" }, "browserslist": { diff --git a/src/config/config.js b/src/config/config.js index 84d95b70a..2b09b9c9b 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -1,14 +1,11 @@ -const spectrum = process.env.REACT_APP_SPECTRUM_BASE_URL - ? process.env.REACT_APP_SPECTRUM_BASE_URL - : window.location.origin; - -const loginUrl = process.env.REACT_APP_LOGIN_BASE_URL - ? process.env.REACT_APP_LOGIN_BASE_URL + '/login' - : window.location.origin + '/login'; +const loginBaseURL = (directory) => { + return (process.env.REACT_APP_LOGIN_BASE_URL || window.location.origin) + directory + '?dest=' + encodeURIComponent(document.location.pathname + document.location.search); +}; const config = { - spectrum, - loginUrl, + spectrum: process.env.REACT_APP_SPECTRUM_BASE_URL || window.location.origin, + loginUrl: loginBaseURL('/auth/openid_connect'), + logoutUrl: loginBaseURL('/logout'), datastores: { list: [ { diff --git a/src/modules/profile/components/Login/index.js b/src/modules/profile/components/Login/index.js index 9a2685d68..e307cb6ad 100644 --- a/src/modules/profile/components/Login/index.js +++ b/src/modules/profile/components/Login/index.js @@ -1,33 +1,24 @@ -import React, { Component } from 'react'; -import { connect } from 'react-redux'; +import React from 'react'; import config from '../../../../config'; import PropTypes from 'prop-types'; -class Login extends Component { - render () { - const authenticated = this.props.profile && this.props.profile.status === 'Logged in'; - const href = config.loginUrl + '?dest=' + encodeURIComponent(document.location.pathname + document.location.search); - const loading = this.props.loading; - - return ( - <> - {this.props.render({ href, authenticated, loading })} - - ); - } +export default function Login ({ text = 'Login', link }) { + return ( +
+ +
+ ); } Login.propTypes = { - profile: PropTypes.object, - loading: PropTypes.bool, - render: PropTypes.func + text: PropTypes.string, + link: PropTypes.string }; - -function mapStateToProps (state) { - return { - profile: state.profile, - loading: !state.profile.status - }; -} - -export default connect(mapStateToProps)(Login);