mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-31 02:26:50 +10:00
Merge pull request #344 from sharetribe/route-handling-and-email-confirmation-fixes
Route handling and email confirmation fixes
This commit is contained in:
commit
98d521d836
5 changed files with 23 additions and 8 deletions
|
|
@ -54,7 +54,7 @@ class RouteComponentRenderer extends Component {
|
|||
|
||||
render() {
|
||||
const { route, match, location, staticContext, flattenedRoutes } = this.props;
|
||||
const { component: RouteComponent } = route;
|
||||
const { component: RouteComponent, authPage = 'SignupPage' } = route;
|
||||
const canShow = this.canShowComponent();
|
||||
if (!canShow) {
|
||||
staticContext.forbidden = true;
|
||||
|
|
@ -65,7 +65,10 @@ class RouteComponentRenderer extends Component {
|
|||
location={location}
|
||||
flattenedRoutes={flattenedRoutes}
|
||||
/>
|
||||
: <NamedRedirect name="SignupPage" state={{ from: match.url }} />;
|
||||
: <NamedRedirect
|
||||
name={authPage}
|
||||
state={{ from: `${location.pathname}${location.search}${location.hash}` }}
|
||||
/>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,9 @@ describe('Application', () => {
|
|||
});
|
||||
|
||||
it('server renders redirects for pages that require authentication', () => {
|
||||
const defaultAuthPath = '/signup';
|
||||
const loginPath = '/login';
|
||||
const signupPath = '/signup';
|
||||
const defaultAuthPath = signupPath;
|
||||
const urlRedirects = {
|
||||
'/l/new': defaultAuthPath,
|
||||
'/l/listing-title-slug/1234/new/description': defaultAuthPath,
|
||||
|
|
@ -80,7 +82,7 @@ describe('Application', () => {
|
|||
'/account/contact-details': defaultAuthPath,
|
||||
'/account/payout-preferences': defaultAuthPath,
|
||||
'/account/security': defaultAuthPath,
|
||||
'/email_verification': defaultAuthPath,
|
||||
'/email_verification': loginPath,
|
||||
};
|
||||
forEach(urlRedirects, (redirectPath, url) => {
|
||||
const context = {};
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ const MapWithGoogleMap = withGoogleMap(props => {
|
|||
const { center, listings, listingOpen, onListingClicked, onMapLoad, zoom } = props;
|
||||
|
||||
const priceLabels = listings.reverse().map(listing => {
|
||||
|
||||
// if the listing is open, don't print price label
|
||||
if (listingOpen && listingOpen.id.uuid === listing.id.uuid) {
|
||||
return null;
|
||||
|
|
@ -105,7 +104,6 @@ export class SearchMapComponent extends Component {
|
|||
}
|
||||
|
||||
onMapClicked(e) {
|
||||
|
||||
// Close open listing popup / infobox, unless the click is attached to a price label
|
||||
const labelClicked = hasParentWithClassName(e.nativeEvent.target, PRICE_LABEL_HANDLE);
|
||||
if (this.state.listingOpen != null && !labelClicked) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
|
|||
import * as propTypes from '../../util/propTypes';
|
||||
import { PageLayout, Topbar } from '../../components';
|
||||
import { EmailVerificationForm } from '../../containers';
|
||||
import { authenticationInProgress } from '../../ducks/Auth.duck';
|
||||
import { logout, authenticationInProgress } from '../../ducks/Auth.duck';
|
||||
import { verify, verificationInProgress } from '../../ducks/EmailVerification.duck';
|
||||
import { manageDisableScrolling, isScrollingDisabled } from '../../ducks/UI.duck';
|
||||
import { parse } from '../../util/urlHelpers';
|
||||
|
|
@ -50,6 +50,8 @@ export const EmailVerificationPageComponent = props => {
|
|||
submitVerification,
|
||||
emailVerificationInProgress,
|
||||
verificationError,
|
||||
location,
|
||||
history,
|
||||
} = props;
|
||||
const title = intl.formatMessage({
|
||||
id: 'EmailVerificationPage.title',
|
||||
|
|
@ -102,7 +104,7 @@ EmailVerificationPageComponent.defaultProps = {
|
|||
verificationError: null,
|
||||
};
|
||||
|
||||
const { bool, func, instanceOf, number } = PropTypes;
|
||||
const { bool, func, instanceOf, number, object, shape, string } = PropTypes;
|
||||
|
||||
EmailVerificationPageComponent.propTypes = {
|
||||
authInfoError: instanceOf(Error),
|
||||
|
|
@ -118,6 +120,14 @@ EmailVerificationPageComponent.propTypes = {
|
|||
submitVerification: func.isRequired,
|
||||
emailVerificationInProgress: bool.isRequired,
|
||||
verificationError: instanceOf(Error),
|
||||
|
||||
// from withRouter
|
||||
history: object.isRequired,
|
||||
location: shape({
|
||||
search: string,
|
||||
}).isRequired,
|
||||
|
||||
// from injectIntl
|
||||
intl: intlShape.isRequired,
|
||||
};
|
||||
|
||||
|
|
@ -150,6 +160,7 @@ const mapStateToProps = state => {
|
|||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onLogout: () => dispatch(logout()),
|
||||
onManageDisableScrolling: (componentId, disableScrolling) =>
|
||||
dispatch(manageDisableScrolling(componentId, disableScrolling)),
|
||||
submitVerification: ({ verificationToken }) => {
|
||||
|
|
|
|||
|
|
@ -309,6 +309,7 @@ const routesConfiguration = [
|
|||
{
|
||||
path: '/email_verification',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
exact: true,
|
||||
name: 'EmailVerificationPage',
|
||||
component: props => <EmailVerificationPage {...props} />,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue