Skip to content

Commit cf9c7cb

Browse files
authored
Fix WPCC redirect (#3281)
1 parent 00a9aa1 commit cf9c7cb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/auth/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ type Props = OwnProps;
3434

3535
export class Auth extends Component<Props> {
3636
state = {
37-
authState: '',
3837
isCreatingAccount: false,
3938
passwordErrorMessage: null,
4039
onLine: window.navigator.onLine,
@@ -543,7 +542,6 @@ export class Auth extends Component<Props> {
543542

544543
onSubmitCode = (event: React.FormEvent) => {
545544
event.preventDefault();
546-
this.setState({ authState: 'login-requested' });
547545
this.setState({
548546
passwordErrorMessage: '',
549547
});
@@ -564,8 +562,8 @@ export class Auth extends Component<Props> {
564562

565563
onWPLogin = () => {
566564
const redirectUrl = encodeURIComponent(config.wpcc_redirect_url);
567-
this.setState({ authState: `app-${cryptoRandomString(20)}` });
568-
const authUrl = `https://public-api.wordpress.com/oauth2/authorize?client_id=${config.wpcc_client_id}&redirect_uri=${redirectUrl}&response_type=code&scope=global&state=${this.state.authState}`;
565+
const savedAuthState = `app-${cryptoRandomString(20)}`;
566+
const authUrl = `https://public-api.wordpress.com/oauth2/authorize?client_id=${config.wpcc_client_id}&redirect_uri=${redirectUrl}&response_type=code&scope=global&state=${savedAuthState}`;
569567

570568
window.electron.send('wpLogin', authUrl);
571569

@@ -596,7 +594,7 @@ export class Auth extends Component<Props> {
596594
return this.authError('An error was encountered while signing in.');
597595
}
598596

599-
if (authState !== this.state.authState) {
597+
if (authState !== savedAuthState) {
600598
return;
601599
}
602600
this.props.tokenLogin(userEmail, simperiumToken);

0 commit comments

Comments
 (0)