Merge pull request #628 from matrix-org/luke/feature-team-reg-auto-join-rooms
Implement auto-join rooms on registration
This commit is contained in:
commit
9e0c7a11d0
2 changed files with 30 additions and 1 deletions
|
@ -57,6 +57,11 @@ module.exports = React.createClass({
|
||||||
"name": React.PropTypes.string,
|
"name": React.PropTypes.string,
|
||||||
// The suffix with which every team email address ends
|
// The suffix with which every team email address ends
|
||||||
"emailSuffix": React.PropTypes.string,
|
"emailSuffix": React.PropTypes.string,
|
||||||
|
// The rooms to use during auto-join
|
||||||
|
"rooms": React.PropTypes.arrayOf(React.PropTypes.shape({
|
||||||
|
"id": React.PropTypes.string,
|
||||||
|
"autoJoin": React.PropTypes.bool,
|
||||||
|
})),
|
||||||
})).required,
|
})).required,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -179,6 +184,26 @@ module.exports = React.createClass({
|
||||||
accessToken: response.access_token
|
accessToken: response.access_token
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Auto-join rooms
|
||||||
|
if (self.props.teamsConfig && self.props.teamsConfig.teams) {
|
||||||
|
for (let i = 0; i < self.props.teamsConfig.teams.length; i++) {
|
||||||
|
let team = self.props.teamsConfig.teams[i];
|
||||||
|
if (self.state.formVals.email.endsWith(team.emailSuffix)) {
|
||||||
|
console.log("User successfully registered with team " + team.name);
|
||||||
|
if (!team.rooms) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
team.rooms.forEach((room) => {
|
||||||
|
if (room.autoJoin) {
|
||||||
|
console.log("Auto-joining " + room.id);
|
||||||
|
MatrixClientPeg.get().joinRoom(room.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (self.props.brand) {
|
if (self.props.brand) {
|
||||||
MatrixClientPeg.get().getPushers().done((resp)=>{
|
MatrixClientPeg.get().getPushers().done((resp)=>{
|
||||||
var pushers = resp.pushers;
|
var pushers = resp.pushers;
|
||||||
|
|
|
@ -116,10 +116,14 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_doSubmit: function() {
|
_doSubmit: function() {
|
||||||
|
let email = this.refs.email.value.trim();
|
||||||
|
if (this.state.selectedTeam) {
|
||||||
|
email += "@" + this.state.selectedTeam.emailSuffix;
|
||||||
|
}
|
||||||
var promise = this.props.onRegisterClick({
|
var promise = this.props.onRegisterClick({
|
||||||
username: this.refs.username.value.trim() || this.props.guestUsername,
|
username: this.refs.username.value.trim() || this.props.guestUsername,
|
||||||
password: this.refs.password.value.trim(),
|
password: this.refs.password.value.trim(),
|
||||||
email: this.refs.email.value.trim()
|
email: email,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (promise) {
|
if (promise) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue