diff options
Diffstat (limited to 'webapp/components/signup')
-rw-r--r-- | webapp/components/signup/signup_controller.jsx | 109 |
1 files changed, 56 insertions, 53 deletions
diff --git a/webapp/components/signup/signup_controller.jsx b/webapp/components/signup/signup_controller.jsx index a4ec26a5f..229e91762 100644 --- a/webapp/components/signup/signup_controller.jsx +++ b/webapp/components/signup/signup_controller.jsx @@ -31,16 +31,15 @@ export default class SignupController extends React.Component { let usedBefore = false; if (props.location.query) { - loading = true; const hash = props.location.query.h; const inviteId = props.location.query.id; - if (hash && hash.length > 0 && !UserStore.getCurrentUser()) { + if (inviteId) { + loading = true; + } else if (hash && !UserStore.getCurrentUser()) { usedBefore = BrowserStore.getGlobalItem(hash); - loading = false; } else if (!inviteId && global.window.mm_config.EnableOpenServer !== 'true' && !UserStore.getNoAccounts()) { noOpenServerError = true; - loading = false; serverError = ( <FormattedMessage id='signup_user_completed.no_open_server' @@ -66,58 +65,62 @@ export default class SignupController extends React.Component { const data = this.props.location.query.d; const inviteId = this.props.location.query.id; - if ((inviteId && inviteId.length > 0) || (hash && hash.length > 0)) { - if (UserStore.getCurrentUser()) { - Client.addUserToTeamFromInvite( - data, - hash, - inviteId, - (team) => { - GlobalActions.emitInitialLoad( - () => { - browserHistory.push('/' + team.name + '/channels/town-square'); - } - ); - }, - (err) => { - this.setState({ // eslint-disable-line react/no-did-mount-set-state - serverError: err.message - }); - } - ); - } else if (!this.state.usedBefore) { - Client.getInviteInfo( - inviteId, - (inviteData) => { - if (!inviteData) { - return; + const userLoggedIn = UserStore.getCurrentUser() != null; + + if ((inviteId || hash) && userLoggedIn) { + Client.addUserToTeamFromInvite( + data, + hash, + inviteId, + (team) => { + GlobalActions.emitInitialLoad( + () => { + browserHistory.push('/' + team.name + '/channels/town-square'); } + ); + }, + (err) => { + this.setState({ // eslint-disable-line react/no-did-mount-set-state + serverError: err.message + }); + } + ); - this.setState({ // eslint-disable-line react/no-did-mount-set-state - serverError: '', - loading: false - }); - }, - () => { - this.setState({ // eslint-disable-line react/no-did-mount-set-state - noOpenServerError: true, - loading: false, - serverError: ( - <FormattedMessage - id='signup_user_completed.invalid_invite' - defaultMessage='The invite link was invalid. Please speak with your Administrator to receive an invitation.' - /> - ) - }); + return; + } + + if (inviteId) { + Client.getInviteInfo( + inviteId, + (inviteData) => { + if (!inviteData) { + return; } - ); - } - } else if (UserStore.getCurrentUser()) { + + this.setState({ // eslint-disable-line react/no-did-mount-set-state + serverError: '', + loading: false + }); + }, + () => { + this.setState({ // eslint-disable-line react/no-did-mount-set-state + noOpenServerError: true, + loading: false, + serverError: ( + <FormattedMessage + id='signup_user_completed.invalid_invite' + defaultMessage='The invite link was invalid. Please speak with your Administrator to receive an invitation.' + /> + ) + }); + } + ); + + return; + } + + if (userLoggedIn) { browserHistory.push('/select_team'); - } else { - this.setState({ // eslint-disable-line react/no-did-mount-set-state - loading: false - }); } } } @@ -337,4 +340,4 @@ export default class SignupController extends React.Component { SignupController.propTypes = { location: React.PropTypes.object -};
\ No newline at end of file +}; |