Skip to content

Commit

Permalink
Merge pull request #268 from LiskHQ/230-fix-login-redirect
Browse files Browse the repository at this point in the history
 Fix redirect from "add account" page - Closes #230
  • Loading branch information
slaweet authored Feb 5, 2018
2 parents 3da30b0 + 915f9f4 commit 0f3dbdc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/components/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const App = () => (
<Route path={`${match.url}/voting/:dialog?`} component={Voting} />
<Route path={`${match.url}/sidechains/:dialog?`} component={Sidechains} />
<Route path={`${match.url}/forging/:dialog?`} component={Forging} />
<Route path={`${match.url}/add-account/:dialog?`} component={Login} />
<Route path='*' component={NotFound} />
</Switch>
</main>
Expand All @@ -52,8 +51,9 @@ const App = () => (
<Route path={`${match.url}${routes.account.short}/:address?`} component={accountTransactions} />
</main>
)} />
<Route exact path='/register' component={Register} />
<Route exact path='/' component={Login} />
<Route exact path={routes.register.url} component={Register} />
<Route path={`${routes.addAccount.url}:dialog?`} component={Login} />
<Route exact path={routes.login.url} component={Login} />
<Route path='*' component={NotFound} />
</Switch>
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import RelativeLink from '../relativeLink';
import routes from './../../constants/routes';

const Header = (props) => {
const shouldShowActionButton = () => !props.isAuthenticated && props.location.pathname !== '/';
const shouldShowActionButton = () => (
!props.isAuthenticated &&
props.location.pathname !== routes.login.url &&
props.location.pathname !== routes.register.url &&
!props.account.loading
);
const shouldShowSearchBar = () => props.location.pathname.includes('explorer') && !props.location.pathname.includes(routes.search.long);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Header', () => {
setActiveDialog: () => { },
account: {},
t: key => key,
location: { pathname: '/register' },
location: { pathname: '/explorer/search' },
isAuthenticated: false,
};
propsMock = sinon.mock(mockInputProps);
Expand Down
3 changes: 2 additions & 1 deletion src/components/savedAccounts/savedAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import LiskAmount from '../liskAmount';
import BackgroundMaker from '../backgroundMaker';
import networks from '../../constants/networks';
import getNetwork from '../../utils/getNetwork';
import routes from '../../constants/routes';

import plusShapeIcon from '../../assets/images/plus-shape.svg';
import circleImage from '../../assets/images/add-id-oval.svg';
Expand Down Expand Up @@ -77,7 +78,7 @@ class SavedAccounts extends React.Component {
<BackgroundMaker />
<h1>{t('Your favorite Lisk IDs')}</h1>
<div className={styles.cardsWrapper} >
<Link to='/main/add-account/?referrer=/main/dashboard/' >
<Link to={`${routes.addAccount.url}?referrer=/main/dashboard/`} >
<div className={`add-lisk-id-card ${styles.card} ${styles.addNew}`} >
<div className={styles.cardIcon}>
<img src={plusShapeIcon} className={styles.plusShapeIcon} />
Expand Down
3 changes: 3 additions & 0 deletions src/constants/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ export default {
wallet: { long: '/main/transactions', short: '/transactions' },
account: { long: '/explorer/accounts', short: '/accounts' },
search: { long: '/explorer/search', short: '/search' },
login: { url: '/' },
addAccount: { url: '/add-account/' },
register: { url: '/register' },
};
4 changes: 2 additions & 2 deletions src/utils/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export default [
params: 'dialog',
name: 'forging',
}, {
regex: /\/main\/add-account(?:\/[^/]*)?$/,
path: '/main/add-account/',
regex: /\/add-account(?:\/[^/]*)?$/,
path: '/add-account/',
params: 'dialog',
name: 'add-account',
}, {
Expand Down

0 comments on commit 0f3dbdc

Please sign in to comment.