Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Support registration & login with phone number#742

Merged
dbkr merged 37 commits into
developfrom
dbkr/msisdn_signin
Mar 9, 2017
Merged

Support registration & login with phone number#742
dbkr merged 37 commits into
developfrom
dbkr/msisdn_signin

Conversation

@dbkr
Copy link
Copy Markdown
Member

@dbkr dbkr commented Mar 7, 2017

A lot of this is adding a CountryDropdown component to select the country for a phone number, and a Dropdown component on which its based. Note that some of the code comes from NetworkDropdown which has not yet been refactored to use Dropdown.

Adds phone number entry fields to login & registration screens
Adds a UI Auth entry component for m.login.msisdn auth
Changes login API to support phone numbers and use new typed-object style identifiers: https://docs.google.com/document/d/1-6ZSSW5YvCGhVFDyD2QExAUAdpCWjccvJT5xiyTTG2Y/edit#

Requires matrix-org/matrix-js-sdk#384
Requires matrix-org/synapse#1971
Requires: element-hq/element-web#3381

dbkr added 24 commits February 2, 2017 10:47
Stop the guest sync, otherwise it gets 401ed for using a guest
access token for a non-guest, causing us to beliebe we've been
logged out.
Now that Signup contains no code whatsoever related to signing up,
rename it to Login. Get rid of the Signup class.
Rendering the whole lot when the component was rendered just makes
the page load really slow, so just show 2 at a time and rely on
type-to-search.

Make type-to-search always display an exact iso2 match first
restProps.onClick = onClick;
restProps.onKeyDown = function(e) {
if (e.keyCode == 13 || e.keyCode == 32) return onClick();
restProps.onKeyUp = function(e) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this changing, ooi?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I was listening for onKeyUp further up the tree and wondering why it wasn't being correctly captured by the AccessibleButton when the focus was there, and it was because it's on KeyDown, so since its generally more correct to use KeyUp than KeyDown, I changed this one. It also was not passing the event through to the onClick handler which was breaking things.

componentWillReceiveProps(nextProps) {
this._reindexChildren(nextProps.children);
this.setState({
highlightedOption: Object.keys(this.childrenByKey)[0],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this not choose a random child?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, done

</div>
}

const menuOptions = this._getMenuOptions();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, yes it was

<AccessibleButton className="mx_Dropdown_input" onClick={this._onInputClick}>
{currentValue}
<span className="mx_Dropdown_arrow"></span>
{menu}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be outside the AccessibleButton?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have commented on why its done this way.


class MenuOption extends React.Component {
constructor(props) {
super(props)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing ;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread src/HtmlUtils.js
}

/**
* @param unicode {integer} One or more integers representing unicode characters
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs much better documentation about what it does and when it is useful.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


const MAX_DISPLAYED_ROWS = 2;

export default class CountryDropdown extends React.Component {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't we decided to stick with old-style React.createClass classes for now, btw?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems so: this makes it consistent with Dropdown which was based on NetworkDropdown though.


propTypes: {
submitAuthDict: React.PropTypes.func.isRequired,
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit sparse.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

this.props.matrixClient.submitMsisdnToken(
this._sid, this.props.clientSecret, this.state.token
).catch((e) => {
this.props.fail(e);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will fall into the then block below with result === undefined, which will cause more exceptions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yep. done.

},

onPhoneCountryChanged: function(country) {
this.setState({phoneCountry: country});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, why are we tracking this (and phoneNumber) as a separate bit of state, rather than passing it in as a prop? it violates the keep-your-state-in-one-place principle of react.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed above

@richvdh richvdh assigned dbkr and unassigned richvdh Mar 8, 2017
@dbkr
Copy link
Copy Markdown
Member Author

dbkr commented Mar 8, 2017

ptal

@dbkr dbkr assigned richvdh and unassigned dbkr Mar 8, 2017
selectedOption: this.props.initialSelectedOption || props.children[0].key,
// The key of the highlighted option
// (the option that would become selected if you pressed enter)
highlightedOption: props.children[0].key,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will blow up if children isn't an array, or is empty - eg on empty search results? we should probably do something better.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

this._reindexChildren(nextProps.children);
this.setState({
highlightedOption: Object.keys(this.childrenByKey)[0],
highlightedOption: nextProps.children[0].key,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

errorText: "Token incorrect",
});
}
}).catch((e) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels weird.

either move this.props.fail(e) to here, or replace catch(...).then(...).catch(...) with then(..., ...).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@richvdh richvdh assigned dbkr and unassigned richvdh Mar 8, 2017
@dbkr
Copy link
Copy Markdown
Member Author

dbkr commented Mar 8, 2017

ptal

@dbkr dbkr assigned richvdh and unassigned dbkr Mar 8, 2017
Assuming [0] of an empty list == undefined doesn't work if you're
then taking a property of it.
Copy link
Copy Markdown
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@richvdh richvdh assigned dbkr and unassigned richvdh Mar 8, 2017
@dbkr dbkr merged commit 0269562 into develop Mar 9, 2017
richvdh added a commit that referenced this pull request Mar 9, 2017
This reverts commit 0269562.

This breaks against the current synapse release. We need to think more
carefully about backwards compatibility.
dbkr added a commit that referenced this pull request Mar 14, 2017
@dbkr dbkr mentioned this pull request Jan 3, 2018
martindale pushed a commit to FabricLabs/matrix-react-sdk that referenced this pull request Dec 8, 2018
Split npm start into an init and watch script
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants