From f5353fcdc54a09cf94e2fca51a70d2733acf24f3 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 23 Jun 2017 13:43:52 +0100 Subject: [PATCH 1/3] Only submit phone number when phone loginType is selected Otherwise submit a phoneNumber and phoneCountry of `null` (when logging in with email or username). Fixes https://github.com/vector-im/riot-web/issues/4000 --- src/components/views/login/PasswordLogin.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/views/login/PasswordLogin.js b/src/components/views/login/PasswordLogin.js index 46a48d14a0..54237bec19 100644 --- a/src/components/views/login/PasswordLogin.js +++ b/src/components/views/login/PasswordLogin.js @@ -69,10 +69,19 @@ class PasswordLogin extends React.Component { onSubmitForm(ev) { ev.preventDefault(); + if (this.state.loginType === PasswordLogin.LOGIN_FIELD_PHONE) { + this.props.onSubmit( + this.state.username, + this.state.phoneCountry, + this.state.phoneNumber, + this.state.password, + ); + return; + } this.props.onSubmit( this.state.username, - this.state.phoneCountry, - this.state.phoneNumber, + null, + null, this.state.password, ); } From c51255da40f2cf69ca1a2d9dc54189621a9a4958 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 23 Jun 2017 14:34:19 +0100 Subject: [PATCH 2/3] Submit empty string username when on phone number login --- src/components/views/login/PasswordLogin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/login/PasswordLogin.js b/src/components/views/login/PasswordLogin.js index 54237bec19..2c125be378 100644 --- a/src/components/views/login/PasswordLogin.js +++ b/src/components/views/login/PasswordLogin.js @@ -71,7 +71,7 @@ class PasswordLogin extends React.Component { ev.preventDefault(); if (this.state.loginType === PasswordLogin.LOGIN_FIELD_PHONE) { this.props.onSubmit( - this.state.username, + '', this.state.phoneCountry, this.state.phoneNumber, this.state.password, From ec36a348be008c84fbd13b80d2c2b2eeab983d4c Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 23 Jun 2017 14:48:15 +0100 Subject: [PATCH 3/3] comment why we send the empty string --- src/components/views/login/PasswordLogin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/login/PasswordLogin.js b/src/components/views/login/PasswordLogin.js index 2c125be378..9f855616fc 100644 --- a/src/components/views/login/PasswordLogin.js +++ b/src/components/views/login/PasswordLogin.js @@ -71,7 +71,7 @@ class PasswordLogin extends React.Component { ev.preventDefault(); if (this.state.loginType === PasswordLogin.LOGIN_FIELD_PHONE) { this.props.onSubmit( - '', + '', // XXX: Synapse breaks if you send null here: this.state.phoneCountry, this.state.phoneNumber, this.state.password,