Support registration & login with phone number#742
Conversation
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) { |
There was a problem hiding this comment.
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], |
There was a problem hiding this comment.
does this not choose a random child?
| </div> | ||
| } | ||
|
|
||
| const menuOptions = this._getMenuOptions(); |
| <AccessibleButton className="mx_Dropdown_input" onClick={this._onInputClick}> | ||
| {currentValue} | ||
| <span className="mx_Dropdown_arrow"></span> | ||
| {menu} |
There was a problem hiding this comment.
should this be outside the AccessibleButton?
There was a problem hiding this comment.
Have commented on why its done this way.
|
|
||
| class MenuOption extends React.Component { | ||
| constructor(props) { | ||
| super(props) |
| } | ||
|
|
||
| /** | ||
| * @param unicode {integer} One or more integers representing unicode characters |
There was a problem hiding this comment.
this needs much better documentation about what it does and when it is useful.
|
|
||
| const MAX_DISPLAYED_ROWS = 2; | ||
|
|
||
| export default class CountryDropdown extends React.Component { |
There was a problem hiding this comment.
haven't we decided to stick with old-style React.createClass classes for now, btw?
There was a problem hiding this comment.
Yeah, seems so: this makes it consistent with Dropdown which was based on NetworkDropdown though.
|
|
||
| propTypes: { | ||
| submitAuthDict: React.PropTypes.func.isRequired, | ||
| }, |
| this.props.matrixClient.submitMsisdnToken( | ||
| this._sid, this.props.clientSecret, this.state.token | ||
| ).catch((e) => { | ||
| this.props.fail(e); |
There was a problem hiding this comment.
this will fall into the then block below with result === undefined, which will cause more exceptions?
| }, | ||
|
|
||
| onPhoneCountryChanged: function(country) { | ||
| this.setState({phoneCountry: country}); |
There was a problem hiding this comment.
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.
Not the array of object keys which has no particular order
|
ptal |
| 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, |
There was a problem hiding this comment.
this will blow up if children isn't an array, or is empty - eg on empty search results? we should probably do something better.
| this._reindexChildren(nextProps.children); | ||
| this.setState({ | ||
| highlightedOption: Object.keys(this.childrenByKey)[0], | ||
| highlightedOption: nextProps.children[0].key, |
| errorText: "Token incorrect", | ||
| }); | ||
| } | ||
| }).catch((e) => { |
There was a problem hiding this comment.
this feels weird.
either move this.props.fail(e) to here, or replace catch(...).then(...).catch(...) with then(..., ...).
|
ptal |
Assuming [0] of an empty list == undefined doesn't work if you're then taking a property of it.
This reverts commit 0269562. This breaks against the current synapse release. We need to think more carefully about backwards compatibility.
Split npm start into an init and watch script
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