feat(api): allow redirects with a returnTo param (#40161)
This commit is contained in:
committed by
GitHub
parent
8fd00afd9c
commit
b2e2f33cf1
@@ -5,7 +5,7 @@ import { createSelector } from 'reselect';
|
||||
import { Grid, Button } from '@freecodecamp/react-bootstrap';
|
||||
import Helmet from 'react-helmet';
|
||||
|
||||
import { apiLocation } from '../../config/env.json';
|
||||
import { apiLocation, homeLocation } from '../../config/env.json';
|
||||
import {
|
||||
signInLoadingSelector,
|
||||
userSelector,
|
||||
@@ -167,7 +167,7 @@ export function ShowSettings(props) {
|
||||
}
|
||||
|
||||
if (!isSignedIn) {
|
||||
navigate(`${apiLocation}/signin?returnTo=settings`);
|
||||
navigate(`${apiLocation}/signin?returnTo=${homeLocation}/settings`);
|
||||
return <Loader fullScreen={true} />;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/* global jest, expect */
|
||||
import React from 'react';
|
||||
import ShallowRenderer from 'react-test-renderer/shallow';
|
||||
import { apiLocation } from '../../config/env.json';
|
||||
import { apiLocation, homeLocation } from '../../config/env.json';
|
||||
|
||||
import { ShowSettings } from './ShowSettings';
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('<ShowSettings />', () => {
|
||||
shallow.render(<ShowSettings {...loggedOutProps} />);
|
||||
expect(navigate).toHaveBeenCalledTimes(1);
|
||||
expect(navigate).toHaveBeenCalledWith(
|
||||
`${apiLocation}/signin?returnTo=settings`
|
||||
`${apiLocation}/signin?returnTo=${homeLocation}/settings`
|
||||
);
|
||||
const result = shallow.getRenderOutput();
|
||||
// Renders Loader rather than ShowSettings
|
||||
|
Reference in New Issue
Block a user