Merge pull request #517 from sharetribe/auth-info-error-handling

Cleanup auth info error handling
This commit is contained in:
Kimmo Puputti 2017-10-24 11:42:50 +03:00 committed by GitHub
commit e276ebb4a6
41 changed files with 53 additions and 208 deletions

View file

@ -54,7 +54,6 @@ class PageComponent extends Component {
const {
className,
rootClassName,
authInfoError,
children,
history,
intl,
@ -77,9 +76,6 @@ class PageComponent extends Component {
// TODO: use FlashMessages for auth errors
/* eslint-disable no-console */
if (authInfoError && console && console.error) {
console.error(authInfoError);
}
if (logoutError && console && console.error) {
console.error(logoutError);
}
@ -184,11 +180,6 @@ class PageComponent extends Component {
{metaTags}
<script type="application/ld+json">{schemaArrayJSONString}</script>
</Helmet>
{authInfoError ? (
<div style={{ color: 'red' }}>
<FormattedMessage id="Page.authInfoFailed" />
</div>
) : null}
{logoutError ? (
<div style={{ color: 'red' }}>
<FormattedMessage id="Page.logoutFailed" />
@ -206,7 +197,6 @@ PageComponent.defaultProps = {
className: null,
rootClassName: null,
children: null,
authInfoError: null,
logoutError: null,
scrollingDisabled: false,
author: null,
@ -226,7 +216,6 @@ PageComponent.propTypes = {
className: string,
rootClassName: string,
children: any,
authInfoError: propTypes.error,
logoutError: propTypes.error,
scrollingDisabled: bool,

View file

@ -35,7 +35,6 @@ import css from './AuthenticationPage.css';
export const AuthenticationPageComponent = props => {
const {
authInfoError,
authInProgress,
currentUser,
intl,
@ -211,7 +210,6 @@ export const AuthenticationPageComponent = props => {
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title={schemaTitle}
scrollingDisabled={scrollingDisabled}
@ -239,7 +237,6 @@ export const AuthenticationPageComponent = props => {
};
AuthenticationPageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
loginError: null,
logoutError: null,
@ -251,7 +248,6 @@ AuthenticationPageComponent.defaultProps = {
const { bool, func, object, oneOf, shape } = PropTypes;
AuthenticationPageComponent.propTypes = {
authInfoError: propTypes.error,
authInProgress: bool.isRequired,
currentUser: propTypes.currentUser,
isAuthenticated: bool.isRequired,
@ -275,10 +271,9 @@ AuthenticationPageComponent.propTypes = {
};
const mapStateToProps = state => {
const { authInfoError, isAuthenticated, loginError, logoutError, signupError } = state.Auth;
const { isAuthenticated, loginError, logoutError, signupError } = state.Auth;
const { currentUser, sendVerificationEmailInProgress, sendVerificationEmailError } = state.user;
return {
authInfoError,
authInProgress: authenticationInProgress(state),
currentUser,
isAuthenticated,

View file

@ -2,7 +2,6 @@
exports[`AuthenticationPageComponent matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
schema={
Object {

View file

@ -125,7 +125,6 @@ export class CheckoutPageComponent extends Component {
render() {
const {
authInfoError,
logoutError,
speculateTransactionInProgress,
speculateTransactionError,
@ -263,7 +262,7 @@ export class CheckoutPageComponent extends Component {
</div>
);
const pageProps = { authInfoError, logoutError, title };
const pageProps = { logoutError, title };
if (isLoading) {
return (
@ -372,7 +371,6 @@ export class CheckoutPageComponent extends Component {
}
CheckoutPageComponent.defaultProps = {
authInfoError: null,
initiateOrderError: null,
listing: null,
bookingDates: null,
@ -385,7 +383,6 @@ CheckoutPageComponent.defaultProps = {
const { func, instanceOf, shape, string, bool } = PropTypes;
CheckoutPageComponent.propTypes = {
authInfoError: propTypes.error,
listing: propTypes.listing,
bookingDates: shape({
bookingStart: instanceOf(Date).isRequired,
@ -423,10 +420,9 @@ const mapStateToProps = state => {
initiateOrderError,
} = state.CheckoutPage;
const { currentUser } = state.user;
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
return {
currentUser,
authInfoError,
logoutError,
bookingDates,
speculateTransactionInProgress,

View file

@ -2,7 +2,6 @@
exports[`CheckoutPage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
title="CheckoutPage.title"
>

View file

@ -25,7 +25,6 @@ import css from './ContactDetailsPage.css';
export const ContactDetailsPageComponent = props => {
const {
authInfoError,
changeEmailError,
changeEmailInProgress,
currentUser,
@ -75,12 +74,7 @@ export const ContactDetailsPageComponent = props => {
) : null;
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title="Contact details"
scrollingDisabled={scrollingDisabled}
>
<Page logoutError={logoutError} title="Contact details" scrollingDisabled={scrollingDisabled}>
<LayoutSideNavigation>
<LayoutWrapperTopbar>
<TopbarContainer
@ -110,7 +104,6 @@ export const ContactDetailsPageComponent = props => {
};
ContactDetailsPageComponent.defaultProps = {
authInfoError: null,
changeEmailError: null,
currentUser: null,
logoutError: null,
@ -120,7 +113,6 @@ ContactDetailsPageComponent.defaultProps = {
const { bool, func } = PropTypes;
ContactDetailsPageComponent.propTypes = {
authInfoError: propTypes.error,
changeEmailError: propTypes.error,
changeEmailInProgress: bool.isRequired,
currentUser: propTypes.currentUser,
@ -135,13 +127,12 @@ ContactDetailsPageComponent.propTypes = {
};
const mapStateToProps = state => {
// Page needs authInfoError and logoutError, Topbar needs isAuthenticated
const { authInfoError, isAuthenticated, logoutError } = state.Auth;
// Page needs logoutError, Topbar needs isAuthenticated
const { isAuthenticated, logoutError } = state.Auth;
// Topbar needs user info.
const { currentUser, sendVerificationEmailInProgress, sendVerificationEmailError } = state.user;
const { changeEmailError, changeEmailInProgress, emailChanged } = state.ContactDetailsPage;
return {
authInfoError,
changeEmailError,
changeEmailInProgress,
currentUser,

View file

@ -2,7 +2,6 @@
exports[`ContactDetailsPage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="Contact details"

View file

@ -43,7 +43,6 @@ const formatRequestData = values => {
// N.B. All the presentational content needs to be extracted to their own components
export const EditListingPageComponent = props => {
const {
authInfoError,
currentUser,
createStripeAccountError,
fetchInProgress,
@ -116,12 +115,7 @@ export const EditListingPageComponent = props => {
: intl.formatMessage({ id: 'EditListingPage.titleEditListing' });
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title={title}
scrollingDisabled={scrollingDisabled}
>
<Page logoutError={logoutError} title={title} scrollingDisabled={scrollingDisabled}>
<TopbarContainer
className={css.topbar}
mobileRootClassName={css.mobileTopbar}
@ -166,7 +160,6 @@ export const EditListingPageComponent = props => {
};
EditListingPageComponent.defaultProps = {
authInfoError: null,
createStripeAccountError: null,
currentUser: null,
currentUserHasOrders: null,
@ -180,7 +173,6 @@ EditListingPageComponent.defaultProps = {
const { bool, func, object, shape, string, oneOf } = PropTypes;
EditListingPageComponent.propTypes = {
authInfoError: propTypes.error,
createStripeAccountError: propTypes.error,
currentUser: propTypes.currentUser,
fetchInProgress: bool.isRequired,
@ -217,7 +209,7 @@ EditListingPageComponent.propTypes = {
const mapStateToProps = state => {
const page = state.EditListingPage;
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
const { createStripeAccountInProgress, createStripeAccountError, currentUser } = state.user;
const fetchInProgress = createStripeAccountInProgress;
@ -227,7 +219,6 @@ const mapStateToProps = state => {
return listings.length === 1 ? listings[0] : null;
};
return {
authInfoError,
createStripeAccountError,
currentUser,
fetchInProgress,

View file

@ -2,7 +2,6 @@
exports[`EditListingPageComponent matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="EditListingPage.titleCreateListing"

View file

@ -44,7 +44,6 @@ const parseVerificationToken = location => {
export const EmailVerificationPageComponent = props => {
const {
authInfoError,
currentUser,
intl,
logoutError,
@ -61,12 +60,7 @@ export const EmailVerificationPageComponent = props => {
const initialValues = { verificationToken: parseVerificationToken(location) };
return (
<Page
title={title}
authInfoError={authInfoError}
logoutError={logoutError}
scrollingDisabled={scrollingDisabled}
>
<Page title={title} logoutError={logoutError} scrollingDisabled={scrollingDisabled}>
<LayoutSingleColumn>
<LayoutWrapperTopbar>
<TopbarContainer />
@ -97,7 +91,6 @@ export const EmailVerificationPageComponent = props => {
};
EmailVerificationPageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
logoutError: null,
verificationError: null,
@ -106,7 +99,6 @@ EmailVerificationPageComponent.defaultProps = {
const { bool, func, shape, string } = PropTypes;
EmailVerificationPageComponent.propTypes = {
authInfoError: propTypes.error,
currentUser: propTypes.currentUser,
logoutError: propTypes.error,
scrollingDisabled: bool.isRequired,
@ -124,11 +116,10 @@ EmailVerificationPageComponent.propTypes = {
};
const mapStateToProps = state => {
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
const { currentUser } = state.user;
const { verificationError } = state.EmailVerification;
return {
authInfoError,
verificationError,
currentUser,
logoutError,

View file

@ -166,7 +166,6 @@ InboxItem.propTypes = {
export const InboxPageComponent = props => {
const {
authInfoError,
currentUser,
fetchInProgress,
fetchOrdersOrSalesError,
@ -261,12 +260,7 @@ export const InboxPageComponent = props => {
const nav = <TabNav rootClassName={css.tabs} tabRootClassName={css.tab} tabs={tabs} />;
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title={title}
scrollingDisabled={scrollingDisabled}
>
<Page logoutError={logoutError} title={title} scrollingDisabled={scrollingDisabled}>
<LayoutSideNavigation>
<LayoutWrapperTopbar>
<TopbarContainer
@ -299,7 +293,6 @@ export const InboxPageComponent = props => {
};
InboxPageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
currentUserHasOrders: null,
fetchOrdersOrSalesError: null,
@ -314,7 +307,6 @@ InboxPageComponent.propTypes = {
tab: string.isRequired,
}).isRequired,
authInfoError: propTypes.error,
currentUser: propTypes.currentUser,
fetchInProgress: bool.isRequired,
fetchOrdersOrSalesError: propTypes.error,
@ -330,10 +322,9 @@ InboxPageComponent.propTypes = {
const mapStateToProps = state => {
const { fetchInProgress, fetchOrdersOrSalesError, pagination, transactionRefs } = state.InboxPage;
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
const { currentUser, currentUserNotificationCount: providerNotificationCount } = state.user;
return {
authInfoError,
currentUser,
fetchInProgress,
fetchOrdersOrSalesError,

View file

@ -2,7 +2,6 @@
exports[`InboxPage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="InboxPage.ordersTitle"
@ -358,7 +357,6 @@ exports[`InboxPage matches snapshot 2`] = `
exports[`InboxPage matches snapshot 3`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="InboxPage.salesTitle"

View file

@ -23,7 +23,7 @@ import twitterImage from '../../assets/saunatimeTwitter-600x314.jpg';
import css from './LandingPage.css';
export const LandingPageComponent = props => {
const { authInfoError, history, intl, location, logoutError, scrollingDisabled } = props;
const { history, intl, location, logoutError, scrollingDisabled } = props;
// Schema for search engines (helps them to understand what this page is about)
// http://schema.org
@ -36,7 +36,6 @@ export const LandingPageComponent = props => {
return (
<Page
className={css.root}
authInfoError={authInfoError}
logoutError={logoutError}
scrollingDisabled={scrollingDisabled}
contentType="website"
@ -70,14 +69,12 @@ export const LandingPageComponent = props => {
};
LandingPageComponent.defaultProps = {
authInfoError: null,
logoutError: null,
};
const { bool, object } = PropTypes;
LandingPageComponent.propTypes = {
authInfoError: propTypes.error,
logoutError: propTypes.error,
scrollingDisabled: bool.isRequired,
@ -90,9 +87,8 @@ LandingPageComponent.propTypes = {
};
const mapStateToProps = state => {
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
return {
authInfoError,
logoutError,
scrollingDisabled: isScrollingDisabled(state),
};

View file

@ -2,7 +2,6 @@
exports[`LandingPage matches snapshot 1`] = `
<Page
authInfoError={null}
contentType="website"
description="LandingPage.schemaDescription"
facebookImages={

View file

@ -147,7 +147,6 @@ export class ListingPageComponent extends Component {
render() {
const {
authInfoError,
currentUser,
getListing,
intl,
@ -341,7 +340,6 @@ export class ListingPageComponent extends Component {
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title={schemaTitle}
scrollingDisabled={scrollingDisabled}
@ -496,7 +494,6 @@ export class ListingPageComponent extends Component {
}
ListingPageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
logoutError: null,
showListingError: null,
@ -516,7 +513,6 @@ ListingPageComponent.propTypes = {
id: string.isRequired,
slug: string,
}).isRequired,
authInfoError: propTypes.error,
currentUser: propTypes.currentUser,
getListing: func.isRequired,
logoutError: propTypes.error,
@ -529,7 +525,7 @@ ListingPageComponent.propTypes = {
const mapStateToProps = state => {
const { showListingError } = state.ListingPage;
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
const { currentUser } = state.user;
const getListing = id => {
@ -538,7 +534,6 @@ const mapStateToProps = state => {
};
return {
authInfoError,
currentUser,
getListing,
logoutError,

View file

@ -2,7 +2,6 @@
exports[`ListingPage matches snapshot 1`] = `
<Page
authInfoError={null}
author="user-1 display name"
canonicalPath="/l/listing1"
contentType="website"

View file

@ -46,7 +46,6 @@ export class ManageListingsPageComponent extends Component {
render() {
const {
authInfoError,
closingListing,
closingListingError,
listings,
@ -114,12 +113,7 @@ export class ManageListingsPageComponent extends Component {
const openingErrorListingId = !!openingListingError && openingListingError.listingId;
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
scrollingDisabled={scrollingDisabled}
title="Manage listings"
>
<Page logoutError={logoutError} scrollingDisabled={scrollingDisabled} title="Manage listings">
<LayoutSingleColumn>
<LayoutWrapperTopbar>
<TopbarContainer currentPage="ManageListingsPage" />
@ -159,7 +153,6 @@ export class ManageListingsPageComponent extends Component {
}
ManageListingsPageComponent.defaultProps = {
authInfoError: null,
listings: [],
logoutError: null,
pagination: null,
@ -174,7 +167,6 @@ ManageListingsPageComponent.defaultProps = {
const { arrayOf, bool, func, object, shape, string } = PropTypes;
ManageListingsPageComponent.propTypes = {
authInfoError: propTypes.error,
closingListing: shape({ uuid: string.isRequired }),
closingListingError: shape({
listingId: propTypes.uuid.isRequired,
@ -209,10 +201,9 @@ const mapStateToProps = state => {
closingListingError,
} = state.ManageListingsPage;
const listings = getListingsById(state, currentPageResultIds);
// Page needs authInfoError and logoutError
const { authInfoError, logoutError } = state.Auth;
// Page needs logoutError
const { logoutError } = state.Auth;
return {
authInfoError,
currentPageResultIds,
listings,
logoutError,

View file

@ -2,7 +2,6 @@
exports[`ContactDetailsPage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="Manage listings"

View file

@ -30,7 +30,7 @@ export class NotFoundPageComponent extends Component {
}
render() {
const { authInfoError, history, logoutError, intl, scrollingDisabled } = this.props;
const { history, logoutError, intl, scrollingDisabled } = this.props;
const title = intl.formatMessage({
id: 'NotFoundPage.title',
@ -46,12 +46,7 @@ export class NotFoundPageComponent extends Component {
};
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title={title}
scrollingDisabled={scrollingDisabled}
>
<Page logoutError={logoutError} title={title} scrollingDisabled={scrollingDisabled}>
<LayoutSingleColumn>
<LayoutWrapperTopbar>
<TopbarContainer />
@ -80,7 +75,6 @@ export class NotFoundPageComponent extends Component {
}
NotFoundPageComponent.defaultProps = {
authInfoError: null,
logoutError: null,
staticContext: {},
};
@ -88,7 +82,6 @@ NotFoundPageComponent.defaultProps = {
const { bool, func, object, shape } = PropTypes;
NotFoundPageComponent.propTypes = {
authInfoError: propTypes.error,
logoutError: propTypes.error,
scrollingDisabled: bool.isRequired,
@ -105,10 +98,9 @@ NotFoundPageComponent.propTypes = {
};
const mapStateToProps = state => {
// Page needs authInfoError and logoutError
const { authInfoError, logoutError } = state.Auth;
// Page needs logoutError
const { logoutError } = state.Auth;
return {
authInfoError,
logoutError,
scrollingDisabled: isScrollingDisabled(state),
};

View file

@ -2,7 +2,6 @@
exports[`NotFoundPageComponent matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="NotFoundPage.title"

View file

@ -27,7 +27,6 @@ import css from './OrderPage.css';
// It show loading data text or OrderDetailsPanel (and later also another panel for messages).
export const OrderPageComponent = props => {
const {
authInfoError,
currentUser,
fetchOrderError,
intl,
@ -77,7 +76,6 @@ export const OrderPageComponent = props => {
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title={intl.formatMessage({ id: 'OrderPage.title' }, { listingTitle })}
scrollingDisabled={scrollingDisabled}
@ -96,7 +94,6 @@ export const OrderPageComponent = props => {
};
OrderPageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
fetchOrderError: null,
logoutError: null,
@ -106,7 +103,6 @@ OrderPageComponent.defaultProps = {
const { bool, oneOf, shape, string } = PropTypes;
OrderPageComponent.propTypes = {
authInfoError: propTypes.error,
currentUser: propTypes.currentUser,
fetchOrderError: propTypes.error,
intl: intlShape.isRequired,
@ -119,13 +115,12 @@ OrderPageComponent.propTypes = {
const mapStateToProps = state => {
const { fetchOrderError, transactionRef } = state.OrderPage;
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
const { currentUser } = state.user;
const transactions = getMarketplaceEntities(state, transactionRef ? [transactionRef] : []);
const transaction = transactions.length > 0 ? transactions[0] : null;
return {
authInfoError,
currentUser,
fetchOrderError,
logoutError,

View file

@ -2,7 +2,6 @@
exports[`OrderPage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="OrderPage.title"

View file

@ -23,7 +23,6 @@ import css from './PasswordChangePage.css';
export const PasswordChangePageComponent = props => {
const {
authInfoError,
changePasswordError,
changePasswordInProgress,
currentUser,
@ -65,12 +64,7 @@ export const PasswordChangePageComponent = props => {
) : null;
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title="Contact details"
scrollingDisabled={scrollingDisabled}
>
<Page logoutError={logoutError} title="Contact details" scrollingDisabled={scrollingDisabled}>
<LayoutSideNavigation>
<LayoutWrapperTopbar>
<TopbarContainer
@ -100,7 +94,6 @@ export const PasswordChangePageComponent = props => {
};
PasswordChangePageComponent.defaultProps = {
authInfoError: null,
changePasswordError: null,
currentUser: null,
logoutError: null,
@ -109,7 +102,6 @@ PasswordChangePageComponent.defaultProps = {
const { bool, func } = PropTypes;
PasswordChangePageComponent.propTypes = {
authInfoError: propTypes.error,
changePasswordError: propTypes.error,
changePasswordInProgress: bool.isRequired,
currentUser: propTypes.currentUser,
@ -121,8 +113,8 @@ PasswordChangePageComponent.propTypes = {
};
const mapStateToProps = state => {
// Page needs authInfoError and logoutError
const { authInfoError, logoutError } = state.Auth;
// Page needs logoutError
const { logoutError } = state.Auth;
// Topbar needs user info.
const {
changePasswordError,
@ -131,7 +123,6 @@ const mapStateToProps = state => {
} = state.PasswordChangePage;
const { currentUser } = state.user;
return {
authInfoError,
changePasswordError,
changePasswordInProgress,
currentUser,

View file

@ -2,7 +2,6 @@
exports[`PasswordChangePage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="Contact details"

View file

@ -31,7 +31,6 @@ import css from './PasswordRecoveryPage.css';
export const PasswordRecoveryPageComponent = props => {
const {
authInfoError,
logoutError,
initialEmail,
submittedEmail,
@ -160,7 +159,7 @@ export const PasswordRecoveryPageComponent = props => {
}
return (
<Page authInfoError={authInfoError} logoutError={logoutError} title={title}>
<Page logoutError={logoutError} title={title}>
<LayoutSingleColumn>
<LayoutWrapperTopbar>
<TopbarContainer />
@ -177,7 +176,6 @@ export const PasswordRecoveryPageComponent = props => {
};
PasswordRecoveryPageComponent.defaultProps = {
authInfoError: null,
logoutError: null,
sendVerificationEmailError: null,
initialEmail: null,
@ -188,7 +186,6 @@ PasswordRecoveryPageComponent.defaultProps = {
const { bool, func, string } = PropTypes;
PasswordRecoveryPageComponent.propTypes = {
authInfoError: propTypes.error,
logoutError: propTypes.error,
initialEmail: string,
submittedEmail: string,
@ -204,8 +201,8 @@ PasswordRecoveryPageComponent.propTypes = {
};
const mapStateToProps = state => {
// Page needs authInfoError and logoutError
const { authInfoError, logoutError } = state.Auth;
// Page needs logoutError
const { logoutError } = state.Auth;
const {
initialEmail,
@ -215,7 +212,6 @@ const mapStateToProps = state => {
passwordRequested,
} = state.PasswordRecoveryPage;
return {
authInfoError,
logoutError,
scrollingDisabled: isScrollingDisabled(state),
initialEmail,

View file

@ -2,7 +2,6 @@
exports[`ContactDetailsPage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
title="PasswordRecoveryPage.title"
>

View file

@ -36,7 +36,6 @@ export class PasswordResetPageComponent extends Component {
}
render() {
const {
authInfoError,
intl,
logoutError,
scrollingDisabled,
@ -122,12 +121,7 @@ export class PasswordResetPageComponent extends Component {
}
return (
<Page
title={title}
authInfoError={authInfoError}
logoutError={logoutError}
scrollingDisabled={scrollingDisabled}
>
<Page title={title} logoutError={logoutError} scrollingDisabled={scrollingDisabled}>
<LayoutSingleColumn>
<LayoutWrapperTopbar>
<TopbarContainer />
@ -145,7 +139,6 @@ export class PasswordResetPageComponent extends Component {
}
PasswordResetPageComponent.defaultProps = {
authInfoError: null,
logoutError: null,
resetPasswordError: null,
};
@ -153,7 +146,6 @@ PasswordResetPageComponent.defaultProps = {
const { bool, func, shape, string } = PropTypes;
PasswordResetPageComponent.propTypes = {
authInfoError: propTypes.error,
logoutError: propTypes.error,
scrollingDisabled: bool.isRequired,
resetPasswordInProgress: bool.isRequired,
@ -170,10 +162,9 @@ PasswordResetPageComponent.propTypes = {
};
const mapStateToProps = state => {
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
const { resetPasswordInProgress, resetPasswordError } = state.PasswordResetPage;
return {
authInfoError,
logoutError,
scrollingDisabled: isScrollingDisabled(state),
resetPasswordInProgress,

View file

@ -15,11 +15,10 @@ import {
import { TopbarContainer } from '../../containers';
export const PayoutPreferencesPageComponent = props => {
const { authInfoError, logoutError, scrollingDisabled } = props;
const { logoutError, scrollingDisabled } = props;
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title="Payout preferences"
scrollingDisabled={scrollingDisabled}
@ -38,23 +37,20 @@ export const PayoutPreferencesPageComponent = props => {
};
PayoutPreferencesPageComponent.defaultProps = {
authInfoError: null,
logoutError: null,
};
const { bool } = PropTypes;
PayoutPreferencesPageComponent.propTypes = {
authInfoError: propTypes.error,
logoutError: propTypes.error,
scrollingDisabled: bool.isRequired,
};
const mapStateToProps = state => {
// Page needs authInfoError and logoutError
const { authInfoError, logoutError } = state.Auth;
// Page needs logoutError
const { logoutError } = state.Auth;
return {
authInfoError,
logoutError,
scrollingDisabled: isScrollingDisabled(state),
};

View file

@ -2,7 +2,6 @@
exports[`PayoutPreferencesPage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="Payout preferences"

View file

@ -8,11 +8,10 @@ import { Page } from '../../components';
import { TopbarContainer } from '../../containers';
export const ProfilePageComponent = props => {
const { authInfoError, logoutError, params, scrollingDisabled } = props;
const { logoutError, params, scrollingDisabled } = props;
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title={`Profile page with display name: ${params.displayName}`}
scrollingDisabled={scrollingDisabled}
@ -23,24 +22,21 @@ export const ProfilePageComponent = props => {
};
ProfilePageComponent.defaultProps = {
authInfoError: null,
logoutError: null,
};
const { bool, shape, string } = PropTypes;
ProfilePageComponent.propTypes = {
authInfoError: propTypes.error,
logoutError: propTypes.error,
params: shape({ displayName: string.isRequired }).isRequired,
scrollingDisabled: bool.isRequired,
};
const mapStateToProps = state => {
// Page needs authInfoError and logoutError
const { authInfoError, logoutError } = state.Auth;
// Page needs logoutError
const { logoutError } = state.Auth;
return {
authInfoError,
logoutError,
scrollingDisabled: isScrollingDisabled(state),
};

View file

@ -2,7 +2,6 @@
exports[`ProfilePage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="Profile page with display name: most-awesome-shop"

View file

@ -34,7 +34,6 @@ export class ProfileSettingsPageComponent extends Component {
}
render() {
const {
authInfoError,
currentUser,
image,
logoutError,
@ -94,7 +93,6 @@ export class ProfileSettingsPageComponent extends Component {
return (
<Page
className={css.root}
authInfoError={authInfoError}
logoutError={logoutError}
title="Profile settings"
scrollingDisabled={scrollingDisabled}
@ -122,7 +120,6 @@ export class ProfileSettingsPageComponent extends Component {
}
ProfileSettingsPageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
logoutError: null,
uploadImageError: null,
@ -133,7 +130,6 @@ ProfileSettingsPageComponent.defaultProps = {
const { bool, func, object, shape, string } = PropTypes;
ProfileSettingsPageComponent.propTypes = {
authInfoError: propTypes.error,
currentUser: propTypes.currentUser,
image: shape({
id: string,
@ -153,8 +149,8 @@ ProfileSettingsPageComponent.propTypes = {
};
const mapStateToProps = state => {
// Page needs authInfoError and logoutError
const { authInfoError, logoutError } = state.Auth;
// Page needs logoutError
const { logoutError } = state.Auth;
const { currentUser } = state.user;
const {
image,
@ -164,7 +160,6 @@ const mapStateToProps = state => {
updateProfileError,
} = state.ProfileSettingsPage;
return {
authInfoError,
currentUser,
image,
logoutError,

View file

@ -2,7 +2,6 @@
exports[`ContactDetailsPage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="Profile settings"

View file

@ -27,7 +27,6 @@ import css from './SalePage.css';
// It show loading data text or SaleDetailsPanel (and later also another panel for messages).
export const SalePageComponent = props => {
const {
authInfoError,
currentUser,
fetchSaleError,
acceptSaleError,
@ -99,7 +98,6 @@ export const SalePageComponent = props => {
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
title={intl.formatMessage({ id: 'SalePage.title' }, { title: listingTitle })}
scrollingDisabled={scrollingDisabled}
@ -120,7 +118,6 @@ export const SalePageComponent = props => {
};
SalePageComponent.defaultProps = {
authInfoError: null,
currentUser: null,
fetchSaleError: null,
acceptSaleError: null,
@ -132,7 +129,6 @@ SalePageComponent.defaultProps = {
const { bool, func, oneOf, shape, string } = PropTypes;
SalePageComponent.propTypes = {
authInfoError: propTypes.error,
currentUser: propTypes.currentUser,
fetchSaleError: propTypes.error,
acceptSaleError: propTypes.error,
@ -158,14 +154,13 @@ const mapStateToProps = state => {
declineInProgress,
transactionRef,
} = state.SalePage;
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
const { currentUser } = state.user;
const transactions = getMarketplaceEntities(state, transactionRef ? [transactionRef] : []);
const transaction = transactions.length > 0 ? transactions[0] : null;
return {
authInfoError,
currentUser,
fetchSaleError,
acceptSaleError,

View file

@ -2,7 +2,6 @@
exports[`SalePage matches snapshot 1`] = `
<Page
authInfoError={null}
logoutError={null}
scrollingDisabled={false}
title="SalePage.title"

View file

@ -144,7 +144,6 @@ export class SearchPageComponent extends Component {
render() {
const {
authInfoError,
intl,
listings,
location,
@ -271,7 +270,6 @@ export class SearchPageComponent extends Component {
/* eslint-disable jsx-a11y/no-static-element-interactions */
return (
<Page
authInfoError={authInfoError}
logoutError={logoutError}
scrollingDisabled={scrollingDisabled}
description={schemaDescription}
@ -342,7 +340,6 @@ export class SearchPageComponent extends Component {
}
SearchPageComponent.defaultProps = {
authInfoError: null,
listings: [],
logoutError: null,
mapListings: [],
@ -355,7 +352,6 @@ SearchPageComponent.defaultProps = {
const { array, bool, func, oneOf, object, shape, string } = PropTypes;
SearchPageComponent.propTypes = {
authInfoError: propTypes.error,
listings: array,
mapListings: array,
logoutError: propTypes.error,
@ -389,7 +385,7 @@ const mapStateToProps = state => {
searchParams,
searchMapListingIds,
} = state.SearchPage;
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
const pageListings = getListingsById(state, currentPageResultIds);
const mapListings = getListingsById(
state,
@ -397,7 +393,6 @@ const mapStateToProps = state => {
);
return {
authInfoError,
listings: pageListings,
logoutError,
mapListings,

View file

@ -2,7 +2,6 @@
exports[`SearchPageComponent matches snapshot 1`] = `
<Page
authInfoError={null}
description="SearchPage.schemaDescription"
logoutError={null}
schema={

View file

@ -18,9 +18,8 @@ StaticPageComponent.propTypes = {
};
const mapStateToProps = state => {
const { authInfoError, logoutError } = state.Auth;
const { logoutError } = state.Auth;
return {
authInfoError,
logoutError,
scrollingDisabled: isScrollingDisabled(state),
};

View file

@ -2,13 +2,12 @@ import { clearCurrentUser, fetchCurrentUser } from './user.duck';
import { storableError } from '../util/errors';
import * as log from '../util/log';
const authenticated = authInfo => authInfo.grantType === 'refresh_token';
const authenticated = authInfo => authInfo && authInfo.grantType === 'refresh_token';
// ================ Action types ================ //
export const AUTH_INFO_REQUEST = 'app/Auth/AUTH_INFO_REQUEST';
export const AUTH_INFO_SUCCESS = 'app/Auth/AUTH_INFO_SUCCESS';
export const AUTH_INFO_ERROR = 'app/Auth/AUTH_INFO_ERROR';
export const LOGIN_REQUEST = 'app/Auth/LOGIN_REQUEST';
export const LOGIN_SUCCESS = 'app/Auth/LOGIN_SUCCESS';
@ -33,7 +32,6 @@ const initialState = {
// auth info
authInfoLoaded: false,
authInfoError: null,
// login
loginError: null,
@ -52,12 +50,9 @@ export default function reducer(state = initialState, action = {}) {
const { type, payload } = action;
switch (type) {
case AUTH_INFO_REQUEST:
return { ...state, authInfoError: null };
return state;
case AUTH_INFO_SUCCESS:
return { ...state, authInfoLoaded: true, isAuthenticated: authenticated(payload) };
case AUTH_INFO_ERROR:
console.error(payload); // eslint-disable-line
return { ...state, authInfoLoaded: true, authInfoError: payload };
case LOGIN_REQUEST:
return {
@ -102,7 +97,6 @@ export const authenticationInProgress = state => {
export const authInfoRequest = () => ({ type: AUTH_INFO_REQUEST });
export const authInfoSuccess = info => ({ type: AUTH_INFO_SUCCESS, payload: info });
export const authInfoError = error => ({ type: AUTH_INFO_ERROR, payload: error, error: true });
export const loginRequest = () => ({ type: LOGIN_REQUEST });
export const loginSuccess = () => ({ type: LOGIN_SUCCESS });
@ -125,7 +119,15 @@ export const authInfo = () => (dispatch, getState, sdk) => {
return sdk
.authInfo()
.then(info => dispatch(authInfoSuccess(info)))
.catch(e => dispatch(authInfoError(storableError(e))));
.catch(e => {
// Requesting auth info just reads the token from the token
// store (i.e. cookies), and should not fail in normal
// circumstances. If it fails, it's due to a programming
// error. In that case we mark the operation done and dispatch
// `null` success action that marks the user as unauthenticated.
log.error(e, 'auth-info-failed');
dispatch(authInfoSuccess(null));
});
};
export const login = (username, password) => (dispatch, getState, sdk) => {

View file

@ -3,7 +3,6 @@ import { clearCurrentUser, currentUserShowRequest, currentUserShowSuccess } from
import reducer, {
authenticationInProgress,
authInfoSuccess,
authInfoError,
login,
loginRequest,
loginSuccess,
@ -51,7 +50,6 @@ describe('Auth duck', () => {
const state = reducer();
expect(state.isAuthenticated).toEqual(false);
expect(state.authInfoLoaded).toEqual(false);
expect(state.authInfoError).toBeNull();
expect(state.loginError).toBeNull();
expect(state.logoutError).toBeNull();
expect(state.signupError).toBeNull();
@ -165,7 +163,6 @@ describe('Auth duck', () => {
const state = reducer(initialState, authInfoSuccess(authInfoLoggedOut));
expect(state.authInfoLoaded).toEqual(true);
expect(state.isAuthenticated).toEqual(false);
expect(state.authInfoError).toBeNull();
});
it('should set initial state for anonymous users', () => {
@ -175,7 +172,6 @@ describe('Auth duck', () => {
const state = reducer(initialState, authInfoSuccess(authInfoAnonymous));
expect(state.authInfoLoaded).toEqual(true);
expect(state.isAuthenticated).toEqual(false);
expect(state.authInfoError).toBeNull();
});
it('should set initial state for unauthenticated users', () => {
@ -185,7 +181,6 @@ describe('Auth duck', () => {
const state = reducer(initialState, authInfoSuccess(authInfoLoggedIn));
expect(state.authInfoLoaded).toEqual(true);
expect(state.isAuthenticated).toEqual(true);
expect(state.authInfoError).toBeNull();
});
});

View file

@ -276,7 +276,6 @@
"OrderPage.fetchOrderFailed": "Fetching order data failed.",
"OrderPage.loadingData": "Loading order data.",
"OrderPage.title": "Order details: {listingTitle}",
"Page.authInfoFailed": "Could not get authentication information.",
"Page.logoutFailed": "Logout failed. Please try again.",
"Page.schemaDescription": "You can book a sauna from Saunatime or get some income by sharing your own sauna",
"Page.schemaTitle": "Book saunas everywhere | {siteTitle}",