Skip to content

Commit

Permalink
Login: Fix suspicious mail back to enter email cycle (#91409)
Browse files Browse the repository at this point in the history
* Change link back

* Switch to use query params

* Fix if
  • Loading branch information
escapemanuele authored Jun 10, 2024
1 parent 52ea1a7 commit 84cb354
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/blocks/login/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class Login extends Component {
twoFactorAuthType: 'link',
oauth2ClientId: this.props.currentQuery?.client_id,
redirectTo: this.props.currentQuery?.redirect_to,
usernameOnly: true,
} );

page( magicLoginUrl );
Expand Down
4 changes: 4 additions & 0 deletions client/blocks/login/login-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,10 @@ export class LoginForm extends Component {
return this.props.translate( 'Your email address or username' );
}

if ( this.props.currentQuery?.username_only === 'true' ) {
return this.props.translate( 'Your username' );
}

return this.isPasswordView() ? (
this.renderChangeUsername()
) : (
Expand Down
5 changes: 5 additions & 0 deletions client/lib/paths/login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function login( {
isPartnerSignup = undefined,
action = undefined,
lostpasswordFlow = undefined,
usernameOnly = undefined,
} = {} ) {
let url = '/log-in';

Expand Down Expand Up @@ -106,5 +107,9 @@ export function login( {
url = addQueryArgs( { lostpassword_flow: true }, url );
}

if ( usernameOnly ) {
url = addQueryArgs( { username_only: true }, url );
}

return url;
}
12 changes: 9 additions & 3 deletions client/login/magic-login/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,14 @@ class MagicLogin extends Component {
locale: this.props.locale,
emailAddress: this.props.query?.email_address,
signupUrl: this.props.query?.signup_url,
usernameOnly: true,
};

page( login( loginParameters ) );
};

renderLinks() {
const { isJetpackLogin, locale, showCheckYourEmail, translate, isWoo } = this.props;
const { isJetpackLogin, locale, showCheckYourEmail, translate, isWoo, query } = this.props;

if ( isWoo ) {
return null;
Expand All @@ -152,7 +153,7 @@ class MagicLogin extends Component {
/>
);
}
if ( this.props.query?.client_id ) {
if ( query?.client_id ) {
return null;
}

Expand All @@ -166,11 +167,16 @@ class MagicLogin extends Component {
signupUrl: this.props.query?.signup_url,
};

let linkBack = translate( 'Enter a password instead' );
if ( query?.username_only === 'true' ) {
linkBack = translate( 'Use username and password instead' );
}

return (
<>
<div className="magic-login__footer">
<a href={ login( loginParameters ) } onClick={ this.onClickEnterPasswordInstead }>
{ translate( 'Enter a password instead' ) }
{ linkBack }
</a>
</div>
<AppPromo
Expand Down

0 comments on commit 84cb354

Please sign in to comment.