Revert "fix: uncaught exception on progressive profiling (#722)" (#725)

This reverts commit 78693f4fc6.
This commit is contained in:
Syed Sajjad Hussain Shah
2023-01-05 17:36:46 +05:00
committed by GitHub
parent 78693f4fc6
commit a7704edb9c
5 changed files with 14 additions and 70 deletions

View File

@@ -9,7 +9,7 @@ import { setCookie } from '../data/utils';
function RedirectLogistration(props) { function RedirectLogistration(props) {
const { const {
finishAuthUrl, redirectUrl, redirectToProgressiveProfilingPage, success, optionalFields, finishAuthUrl, redirectUrl, redirectToWelcomePage, success, optionalFields,
} = props; } = props;
let finalRedirectUrl = ''; let finalRedirectUrl = '';
@@ -25,7 +25,7 @@ function RedirectLogistration(props) {
} }
// Redirect to Progressive Profiling after successful registration // Redirect to Progressive Profiling after successful registration
if (redirectToProgressiveProfilingPage) { if (redirectToWelcomePage) {
// TODO: Do we still need this cookie? // TODO: Do we still need this cookie?
setCookie('van-504-returning-user', true); setCookie('van-504-returning-user', true);
const registrationResult = { redirectUrl: finalRedirectUrl, success }; const registrationResult = { redirectUrl: finalRedirectUrl, success };
@@ -50,7 +50,7 @@ RedirectLogistration.defaultProps = {
finishAuthUrl: null, finishAuthUrl: null,
success: false, success: false,
redirectUrl: '', redirectUrl: '',
redirectToProgressiveProfilingPage: false, redirectToWelcomePage: false,
optionalFields: {}, optionalFields: {},
}; };
@@ -58,7 +58,7 @@ RedirectLogistration.propTypes = {
finishAuthUrl: PropTypes.string, finishAuthUrl: PropTypes.string,
success: PropTypes.bool, success: PropTypes.bool,
redirectUrl: PropTypes.string, redirectUrl: PropTypes.string,
redirectToProgressiveProfilingPage: PropTypes.bool, redirectToWelcomePage: PropTypes.bool,
optionalFields: PropTypes.shape({}), optionalFields: PropTypes.shape({}),
}; };

View File

@@ -23,21 +23,15 @@ const reducer = (state = defaultState, action) => {
...state, ...state,
thirdPartyAuthApiStatus: PENDING_STATE, thirdPartyAuthApiStatus: PENDING_STATE,
}; };
case THIRD_PARTY_AUTH_CONTEXT.SUCCESS: { case THIRD_PARTY_AUTH_CONTEXT.SUCCESS:
const extendedProfile = action.payload.optionalFields.extended_profile;
const extendedProfileArray = extendedProfile && JSON.parse(extendedProfile.replaceAll('\'', '"'));
return { return {
...state, ...state,
extendedProfile: extendedProfileArray, extendedProfile: action.payload.fieldDescriptions.extended_profile,
fieldDescriptions: action.payload.fieldDescriptions.fields, fieldDescriptions: action.payload.fieldDescriptions.fields,
optionalFields: { optionalFields: action.payload.optionalFields,
...action.payload.optionalFields,
extended_profile: extendedProfileArray,
},
thirdPartyAuthContext: action.payload.thirdPartyAuthContext, thirdPartyAuthContext: action.payload.thirdPartyAuthContext,
thirdPartyAuthApiStatus: COMPLETE_STATE, thirdPartyAuthApiStatus: COMPLETE_STATE,
}; };
}
case THIRD_PARTY_AUTH_CONTEXT.FAILURE: case THIRD_PARTY_AUTH_CONTEXT.FAILURE:
return { return {
...state, ...state,

View File

@@ -1,49 +0,0 @@
import { THIRD_PARTY_AUTH_CONTEXT } from '../actions';
import reducer from '../reducers';
describe('common components reducer', () => {
it('should convert extended profile from string to array', () => {
const state = {
extendedProfile: [],
fieldDescriptions: {},
optionalFields: {},
thirdPartyAuthApiStatus: null,
thirdPartyAuthContext: {
currentProvider: null,
finishAuthUrl: null,
countryCode: null,
providers: [],
secondaryProviders: [],
pipelineUserDetails: null,
},
};
const fieldDescriptions = {
fields: [],
extended_profile: "['state', 'profession']",
};
const optionalFields = {
fields: [],
extended_profile: "['state', 'profession']",
};
const thirdPartyAuthContext = { ...state.thirdPartyAuthContext };
const action = {
type: THIRD_PARTY_AUTH_CONTEXT.SUCCESS,
payload: { fieldDescriptions, optionalFields, thirdPartyAuthContext },
};
expect(
reducer(state, action),
).toEqual(
{
...state,
extendedProfile: ['state', 'profession'],
fieldDescriptions: [],
optionalFields: {
fields: [],
extended_profile: ['state', 'profession'],
},
thirdPartyAuthApiStatus: 'complete',
},
);
});
});

View File

@@ -46,13 +46,11 @@ const ProgressiveProfiling = (props) => {
useEffect(() => { useEffect(() => {
configureAuth(AxiosJwtAuthService, { loggingService: getLoggingService(), config: getConfig() }); configureAuth(AxiosJwtAuthService, { loggingService: getLoggingService(), config: getConfig() });
ensureAuthenticatedUser(DASHBOARD_URL) ensureAuthenticatedUser(DASHBOARD_URL).then(() => {
.then(() => { hydrateAuthenticatedUser().then(() => {
hydrateAuthenticatedUser().then(() => { setReady(true);
setReady(true); });
}); });
})
.catch(() => {});
if (props.location.state && props.location.state.registrationResult) { if (props.location.state && props.location.state.registrationResult) {
setRegistrationResult(props.location.state.registrationResult); setRegistrationResult(props.location.state.registrationResult);
@@ -196,6 +194,7 @@ const ProgressiveProfiling = (props) => {
}; };
ProgressiveProfiling.propTypes = { ProgressiveProfiling.propTypes = {
// eslint-disable-next-line react/no-unused-prop-types
formRenderState: PropTypes.string.isRequired, formRenderState: PropTypes.string.isRequired,
intl: intlShape.isRequired, intl: intlShape.isRequired,
location: PropTypes.shape({ location: PropTypes.shape({

View File

@@ -461,7 +461,7 @@ const RegistrationPage = (props) => {
redirectUrl={registrationResult.redirectUrl} redirectUrl={registrationResult.redirectUrl}
finishAuthUrl={finishAuthUrl} finishAuthUrl={finishAuthUrl}
optionalFields={optionalFields} optionalFields={optionalFields}
redirectToProgressiveProfilingPage={ redirectToWelcomePage={
getConfig().ENABLE_PROGRESSIVE_PROFILING_ON_AUTHN && Object.keys(optionalFields).length !== 0 getConfig().ENABLE_PROGRESSIVE_PROFILING_ON_AUTHN && Object.keys(optionalFields).length !== 0
} }
/> />