Improve routing changes

- Add hash to saved from page
 - Use authPage instead of preferLogin for more flexibility
This commit is contained in:
Kimmo Puputti 2017-08-16 09:09:52 +03:00
parent 9027d07a84
commit 2b359caa0a
2 changed files with 4 additions and 5 deletions

View file

@ -54,12 +54,11 @@ class RouteComponentRenderer extends Component {
render() {
const { route, match, location, staticContext, flattenedRoutes } = this.props;
const { component: RouteComponent, preferLogin = false } = route;
const { component: RouteComponent, authPage = 'SignupPage' } = route;
const canShow = this.canShowComponent();
if (!canShow) {
staticContext.forbidden = true;
}
const authPageName = preferLogin ? 'LoginPage' : 'SignupPage';
return canShow
? <RouteComponent
params={match.params}
@ -67,8 +66,8 @@ class RouteComponentRenderer extends Component {
flattenedRoutes={flattenedRoutes}
/>
: <NamedRedirect
name={authPageName}
state={{ from: `${location.pathname}${location.search}` }}
name={authPage}
state={{ from: `${location.pathname}${location.search}${location.hash}` }}
/>;
}
}

View file

@ -309,7 +309,7 @@ const routesConfiguration = [
{
path: '/email_verification',
auth: true,
preferLogin: true,
authPage: 'LoginPage',
exact: true,
name: 'EmailVerificationPage',
component: props => <EmailVerificationPage {...props} />,