Skip to content

Commit

Permalink
use tenant, okapiUrl from store in LoginCtrl.js
Browse files Browse the repository at this point in the history
  • Loading branch information
aidynoJ committed Feb 5, 2025
1 parent 2c94840 commit 5ce3d7a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/Login/LoginCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class LoginCtrl extends Component {
static propTypes = {
authFailure: PropTypes.arrayOf(PropTypes.object),
ssoEnabled: PropTypes.bool,
okapiUrl: PropTypes.string.isRequired,
tenant: PropTypes.string.isRequired,
autoLogin: PropTypes.shape({
username: PropTypes.string.isRequired,
password: PropTypes.string.isRequired,
Expand All @@ -35,9 +37,6 @@ class LoginCtrl extends Component {

constructor(props) {
super(props);
// store is already available on login page with okapi data
this.okapiUrl = this.constructor.contextType.store.getState().okapi.url;
this.tenant = this.constructor.contextType.store.getState().okapi.tenant;
if (props.autoLogin && props.autoLogin.username) {
this.handleSubmit(props.autoLogin);
}
Expand All @@ -54,15 +53,15 @@ class LoginCtrl extends Component {
}

handleSubmit = (data) => {
return requestLogin(this.okapiUrl, this.context.store, this.tenant, data)
return requestLogin(this.props.okapiUrl, this.context.store, this.tenant, data)
.then(this.handleSuccessfulLogin)
.catch(e => {
console.error(e); // eslint-disable-line no-console
});
}

handleSSOLogin = () => {
requestSSOLogin(this.okapiUrl, this.tenant);
requestSSOLogin(this.props.okapiUrl, this.props.tenant);
}

render() {
Expand All @@ -82,6 +81,8 @@ class LoginCtrl extends Component {
const mapStateToProps = state => ({
authFailure: state.okapi.authFailure,
ssoEnabled: state.okapi.ssoEnabled,
okapiUrl: state.okapi.url,
tenant: state.okapi.tenant,
});
const mapDispatchToProps = dispatch => ({
clearAuthErrors: () => dispatch(setAuthError([])),
Expand Down

0 comments on commit 5ce3d7a

Please sign in to comment.