mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Fix extra location state modifications that caused weird redirects
This commit is contained in:
parent
067f5abce8
commit
99c9a67a4b
1 changed files with 6 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import React, { PropTypes } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import { PageLayout, NamedLink } from '../../components';
|
||||
import { PageLayout, NamedLink, NamedRedirect } from '../../components';
|
||||
import { LoginForm, SignUpForm } from '../../containers';
|
||||
import { login } from '../../ducks/Auth.ducks';
|
||||
|
||||
|
|
@ -10,9 +10,11 @@ export const AuthenticationPageComponent = props => {
|
|||
const isLogin = tab === 'login';
|
||||
const from = location.state && location.state.from ? location.state.from : null;
|
||||
|
||||
const authRedirect = from ? <Redirect to={from} /> : <NamedRedirect name="LandingPage" />;
|
||||
|
||||
return (
|
||||
<PageLayout title={`Authentication page: ${tab} tab`}>
|
||||
{isAuthenticated ? <Redirect to={from || '/'} /> : null}
|
||||
{isAuthenticated ? authRedirect : null}
|
||||
{from
|
||||
? <p>
|
||||
You must log in to view the page at
|
||||
|
|
@ -21,8 +23,8 @@ export const AuthenticationPageComponent = props => {
|
|||
: null}
|
||||
{isLogin ? <LoginForm onSubmit={onLoginSubmit} /> : <SignUpForm onSubmit={onSignUpSubmit} />}
|
||||
{isLogin
|
||||
? <NamedLink name="SignUpPage" to={{ state: { from: from || '/' } }}>Sign up</NamedLink>
|
||||
: <NamedLink name="LogInPage" to={{ state: { from: from || '/' } }}>Log in</NamedLink>}
|
||||
? <NamedLink name="SignUpPage" to={{ state: from ? { from } : null }}>Sign up</NamedLink>
|
||||
: <NamedLink name="LogInPage" to={{ state: from ? { from } : null }}>Log in</NamedLink>}
|
||||
</PageLayout>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue