Merge pull request #5629 from PunitLodha/punit/add_email_bug_fix

Add email only if the verification is complete
This commit is contained in:
J. Ryan Stinnett 2021-02-24 11:28:57 +00:00 committed by GitHub
commit 9a56a2efa5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 15 deletions

View file

@ -178,19 +178,23 @@ export default class EmailAddresses extends React.Component {
e.preventDefault(); e.preventDefault();
this.setState({continueDisabled: true}); this.setState({continueDisabled: true});
this.state.addTask.checkEmailLinkClicked().then(() => { this.state.addTask.checkEmailLinkClicked().then(([finished]) => {
const email = this.state.newEmailAddress; let newEmailAddress = this.state.newEmailAddress;
if (finished) {
const email = this.state.newEmailAddress;
const emails = [
...this.props.emails,
{ address: email, medium: "email" },
];
this.props.onEmailsChange(emails);
newEmailAddress = "";
}
this.setState({ this.setState({
addTask: null, addTask: null,
continueDisabled: false, continueDisabled: false,
verifying: false, verifying: false,
newEmailAddress: "", newEmailAddress,
}); });
const emails = [
...this.props.emails,
{ address: email, medium: "email" },
];
this.props.onEmailsChange(emails);
}).catch((err) => { }).catch((err) => {
this.setState({continueDisabled: false}); this.setState({continueDisabled: false});
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");

View file

@ -177,21 +177,25 @@ export default class PhoneNumbers extends React.Component {
this.setState({continueDisabled: true}); this.setState({continueDisabled: true});
const token = this.state.newPhoneNumberCode; const token = this.state.newPhoneNumberCode;
const address = this.state.verifyMsisdn; const address = this.state.verifyMsisdn;
this.state.addTask.haveMsisdnToken(token).then(() => { this.state.addTask.haveMsisdnToken(token).then(([finished]) => {
let newPhoneNumber = this.state.newPhoneNumber;
if (finished) {
const msisdns = [
...this.props.msisdns,
{ address, medium: "msisdn" },
];
this.props.onMsisdnsChange(msisdns);
newPhoneNumber = "";
}
this.setState({ this.setState({
addTask: null, addTask: null,
continueDisabled: false, continueDisabled: false,
verifying: false, verifying: false,
verifyMsisdn: "", verifyMsisdn: "",
verifyError: null, verifyError: null,
newPhoneNumber: "", newPhoneNumber,
newPhoneNumberCode: "", newPhoneNumberCode: "",
}); });
const msisdns = [
...this.props.msisdns,
{ address, medium: "msisdn" },
];
this.props.onMsisdnsChange(msisdns);
}).catch((err) => { }).catch((err) => {
this.setState({continueDisabled: false}); this.setState({continueDisabled: false});
if (err.errcode !== 'M_THREEPID_AUTH_FAILED') { if (err.errcode !== 'M_THREEPID_AUTH_FAILED') {