fix(i18n): redirect based on Referer header (#40512)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Mrugesh Mohapatra
2020-12-21 22:23:06 +05:30
committed by Mrugesh Mohapatra
parent a3b1b52cdd
commit 77c46dba2c
10 changed files with 162 additions and 78 deletions

View File

@@ -5,7 +5,7 @@ import { createSelector } from 'reselect';
import { Grid, Button } from '@freecodecamp/react-bootstrap';
import Helmet from 'react-helmet';
import { apiLocation, homeLocation } from '../../config/env.json';
import { apiLocation } from '../../config/env.json';
import {
signInLoadingSelector,
userSelector,
@@ -169,7 +169,7 @@ export function ShowSettings(props) {
}
if (!isSignedIn) {
navigate(`${apiLocation}/signin?returnTo=${homeLocation}/settings`);
navigate(`${apiLocation}/signin`);
return <Loader fullScreen={true} />;
}

View File

@@ -1,7 +1,7 @@
/* global jest, expect */
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import { apiLocation, homeLocation } from '../../config/env.json';
import { apiLocation } from '../../config/env.json';
import { ShowSettings } from './ShowSettings';
@@ -22,9 +22,7 @@ describe('<ShowSettings />', () => {
const shallow = new ShallowRenderer();
shallow.render(<ShowSettings {...loggedOutProps} />);
expect(navigate).toHaveBeenCalledTimes(1);
expect(navigate).toHaveBeenCalledWith(
`${apiLocation}/signin?returnTo=${homeLocation}/settings`
);
expect(navigate).toHaveBeenCalledWith(`${apiLocation}/signin`);
const result = shallow.getRenderOutput();
// Renders Loader rather than ShowSettings
expect(result.type.displayName).toBe('Loader');

View File

@@ -27,9 +27,7 @@ function Login(props) {
children,
isSignedIn
} = props;
const href = isSignedIn
? `${homeLocation}/learn`
: `${apiLocation}/signin?returnTo=${homeLocation}/learn`;
const href = isSignedIn ? `${homeLocation}/learn` : `${apiLocation}/signin`;
return (
<Button
bsStyle='default'