fix: welcome page redirection (#309)
* fix: welcome page redirection Redirect ot finish auth URL if present upon clicking submit or skip on welcome page. * Update RedirectLogistration.jsx nit
This commit is contained in:
@@ -11,6 +11,7 @@ function RedirectLogistration(props) {
|
||||
const {
|
||||
finishAuthUrl, redirectUrl, redirectToWelcomePage, success,
|
||||
} = props;
|
||||
let finalRedirectUrl = '';
|
||||
|
||||
if (success) {
|
||||
// If we're in a third party auth pipeline, we must complete the pipeline
|
||||
@@ -18,15 +19,19 @@ function RedirectLogistration(props) {
|
||||
// Note: For multiple enterprise use case, we need to make sure that user first visits the
|
||||
// enterprise selection page and then complete the auth workflow
|
||||
if (finishAuthUrl && !redirectUrl.includes(finishAuthUrl)) {
|
||||
window.location.href = getConfig().LMS_BASE_URL + finishAuthUrl;
|
||||
} else if (redirectToWelcomePage) {
|
||||
const welcomeProps = { redirectUrl, success };
|
||||
return <Redirect to={WELCOME_PAGE} registrationResult={welcomeProps} />;
|
||||
finalRedirectUrl = getConfig().LMS_BASE_URL + finishAuthUrl;
|
||||
} else {
|
||||
finalRedirectUrl = redirectUrl;
|
||||
}
|
||||
|
||||
if (redirectToWelcomePage) {
|
||||
// use this component to redirect WelcomePage after successful registration
|
||||
// return <Redirect to={WELCOME_PAGE} />;
|
||||
window.location.href = redirectUrl;
|
||||
const registrationResult = { redirectUrl: finalRedirectUrl, success };
|
||||
return <Redirect to={{ pathname: WELCOME_PAGE, state: { registrationResult } }} />;
|
||||
}
|
||||
|
||||
window.location.href = finalRedirectUrl;
|
||||
}
|
||||
return <></>;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { Helmet } from 'react-helmet';
|
||||
|
||||
import { getConfig } from '@edx/frontend-platform';
|
||||
@@ -17,12 +16,12 @@ import {
|
||||
import messages from './messages';
|
||||
|
||||
import { EDUCATION_LEVELS, GENDER_OPTIONS, YEAR_OF_BIRTH_OPTIONS } from '../register/data/constants';
|
||||
import { registrationRequestSelector } from '../register/data/selectors';
|
||||
import { AuthnValidationFormGroup } from '../common-components';
|
||||
import { DEFAULT_REDIRECT_URL } from '../data/constants';
|
||||
|
||||
const WelcomePage = (props) => {
|
||||
const { intl, registrationResult } = props;
|
||||
const { intl } = props;
|
||||
const [registrationResult, setRegistrationResult] = useState({});
|
||||
const [values, setValues] = useState({});
|
||||
const [ready, setReady] = useState(false);
|
||||
const DASHBOARD_URL = getConfig().LMS_BASE_URL.concat(DEFAULT_REDIRECT_URL);
|
||||
@@ -33,11 +32,15 @@ const WelcomePage = (props) => {
|
||||
setReady(true);
|
||||
});
|
||||
});
|
||||
|
||||
if (props.location.state && props.location.state.registrationResult) {
|
||||
setRegistrationResult(props.location.state.registrationResult);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const authenticatedUser = getAuthenticatedUser();
|
||||
|
||||
if (!registrationResult.redirectUrl) {
|
||||
if (!props.location.state || !props.location.state.registrationResult) {
|
||||
global.location.assign(DASHBOARD_URL);
|
||||
return null;
|
||||
}
|
||||
@@ -188,21 +191,13 @@ const WelcomePage = (props) => {
|
||||
|
||||
WelcomePage.propTypes = {
|
||||
intl: intlShape.isRequired,
|
||||
registrationResult: PropTypes.shape({
|
||||
redirectUrl: PropTypes.string,
|
||||
success: PropTypes.bool,
|
||||
location: PropTypes.shape({
|
||||
state: PropTypes.object,
|
||||
}),
|
||||
};
|
||||
|
||||
WelcomePage.defaultProps = {
|
||||
registrationResult: {},
|
||||
location: { state: {} },
|
||||
};
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const registrationResult = registrationRequestSelector(state);
|
||||
return { registrationResult };
|
||||
};
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
)(injectIntl(WelcomePage));
|
||||
export default (injectIntl(WelcomePage));
|
||||
|
||||
Reference in New Issue
Block a user