Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Social login: Catch inaccessible sessionStorage errors #88791

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions client/blocks/signup-form/social.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { localizeUrl } from '@automattic/i18n-utils';
import { localize } from 'i18n-calypso';
import PropTypes from 'prop-types';
import { Component } from 'react';
Expand All @@ -7,6 +8,7 @@ import { isWooOAuth2Client } from 'calypso/lib/oauth2-clients';
import { login } from 'calypso/lib/paths';
import { isWpccFlow } from 'calypso/signup/is-flow';
import { recordTracksEvent } from 'calypso/state/analytics/actions';
import { errorNotice } from 'calypso/state/notices/actions';
import { getCurrentOAuth2Client } from 'calypso/state/oauth2-clients/ui/selectors';
import getCurrentQueryArguments from 'calypso/state/selectors/get-current-query-arguments';
import getCurrentRoute from 'calypso/state/selectors/get-current-route';
Expand Down Expand Up @@ -108,8 +110,27 @@ class SocialSignupForm extends Component {
trackLoginAndRememberRedirect = ( service ) => {
this.trackSocialSignup( service );

if ( this.props.redirectToAfterLoginUrl && typeof window !== 'undefined' ) {
window.sessionStorage.setItem( 'signup_redirect_to', this.props.redirectToAfterLoginUrl );
try {
if ( this.props.redirectToAfterLoginUrl && typeof window !== 'undefined' ) {
window.sessionStorage.setItem( 'signup_redirect_to', this.props.redirectToAfterLoginUrl );
}
} catch ( error ) {
this.props.showErrorNotice(
this.props.translate(
'Error accessing sessionStorage. {{a}}Please check your browser settings{{/a}}.',
{
components: {
a: (
<a
href={ localizeUrl( 'https://wordpress.com/support/browser-issues/' ) }
target="_blank"
rel="noreferrer"
/>
),
},
}
)
);
}
};

Expand Down Expand Up @@ -147,5 +168,5 @@ export default connect(
isWooCommerceCoreProfilerFlow( state ),
};
},
{ recordTracksEvent }
{ recordTracksEvent, showErrorNotice: errorNotice }
)( localize( SocialSignupForm ) );
Loading