Look up bound mxid for the invited email address on the ID server and warn if it doesn't match our account.
parent
f1844a99e7
commit
97c765f457
|
@ -18,6 +18,7 @@ limitations under the License.
|
|||
|
||||
var React = require('react');
|
||||
var sdk = require('../../../index');
|
||||
var MatrixClientPeg = require('../../../MatrixClientPeg');
|
||||
|
||||
module.exports = React.createClass({
|
||||
displayName: 'RoomPreviewBar',
|
||||
|
@ -45,10 +46,34 @@ module.exports = React.createClass({
|
|||
};
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
busy: false
|
||||
}
|
||||
},
|
||||
|
||||
componentWillMount: function() {
|
||||
// If this is an invite and we've been told what email
|
||||
// address was invited, fetch the user's list of 3pids
|
||||
// so we can check them against the one that was invited
|
||||
if (this.props.inviterName && this.props.invitedEmail) {
|
||||
this.setState({busy: true});
|
||||
MatrixClientPeg.get().lookupThreePid(
|
||||
'email', this.props.invitedEmail
|
||||
).finally(() => {
|
||||
this.setState({busy: false});
|
||||
}).done((result) => {
|
||||
this.setState({invitedEmailMxid: result.mxid});
|
||||
}, (err) => {
|
||||
this.setState({threePidFetchError: err});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var joinBlock, previewBlock;
|
||||
|
||||
if (this.props.spinner) {
|
||||
if (this.props.spinner || this.state.busy) {
|
||||
var Spinner = sdk.getComponent("elements.Spinner");
|
||||
return (<div className="mx_RoomPreviewBar">
|
||||
<Spinner />
|
||||
|
@ -56,6 +81,21 @@ module.exports = React.createClass({
|
|||
}
|
||||
|
||||
if (this.props.inviterName) {
|
||||
var emailMatchBlock;
|
||||
if (this.props.invitedEmail) {
|
||||
if (this.state.threePidFetchError) {
|
||||
emailMatchBlock = <div className="error">
|
||||
Vector was unable to ascertain that the addres this invite was
|
||||
sent to matches one associated with your account.
|
||||
</div>
|
||||
} else if (this.state.invitedEmailMxid != MatrixClientPeg.get().credentials.userId) {
|
||||
emailMatchBlock = <div className="warning">
|
||||
<img src="img/warning.svg" width="24" height="23" title= "/!\\" alt="/!\\" />
|
||||
This invitation was sent to <span className="email">{this.props.invitedEmail}</span>
|
||||
which is not publicly associated with your account.
|
||||
</div>
|
||||
}
|
||||
}
|
||||
joinBlock = (
|
||||
<div>
|
||||
<div className="mx_RoomPreviewBar_invite_text">
|
||||
|
@ -64,7 +104,7 @@ module.exports = React.createClass({
|
|||
<div className="mx_RoomPreviewBar_join_text">
|
||||
Would you like to <a onClick={ this.props.onJoinClick }>accept</a> or <a onClick={ this.props.onRejectClick }>decline</a> this invitation?
|
||||
</div>
|
||||
<div>{this.props.invitedEmail} was invited</div>
|
||||
{emailMatchBlock}
|
||||
</div>
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue