Fix email invitations (#3964)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
35b816b922
Коммит
558821bc54
@@ -31,16 +31,15 @@ export default class SignupController extends React.Component {
|
|||||||
let usedBefore = false;
|
let usedBefore = false;
|
||||||
|
|
||||||
if (props.location.query) {
|
if (props.location.query) {
|
||||||
loading = true;
|
|
||||||
const hash = props.location.query.h;
|
const hash = props.location.query.h;
|
||||||
const inviteId = props.location.query.id;
|
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);
|
usedBefore = BrowserStore.getGlobalItem(hash);
|
||||||
loading = false;
|
|
||||||
} else if (!inviteId && global.window.mm_config.EnableOpenServer !== 'true' && !UserStore.getNoAccounts()) {
|
} else if (!inviteId && global.window.mm_config.EnableOpenServer !== 'true' && !UserStore.getNoAccounts()) {
|
||||||
noOpenServerError = true;
|
noOpenServerError = true;
|
||||||
loading = false;
|
|
||||||
serverError = (
|
serverError = (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='signup_user_completed.no_open_server'
|
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 data = this.props.location.query.d;
|
||||||
const inviteId = this.props.location.query.id;
|
const inviteId = this.props.location.query.id;
|
||||||
|
|
||||||
if ((inviteId && inviteId.length > 0) || (hash && hash.length > 0)) {
|
const userLoggedIn = UserStore.getCurrentUser() != null;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({ // eslint-disable-line react/no-did-mount-set-state
|
if ((inviteId || hash) && userLoggedIn) {
|
||||||
serverError: '',
|
Client.addUserToTeamFromInvite(
|
||||||
loading: false
|
data,
|
||||||
});
|
hash,
|
||||||
},
|
inviteId,
|
||||||
() => {
|
(team) => {
|
||||||
this.setState({ // eslint-disable-line react/no-did-mount-set-state
|
GlobalActions.emitInitialLoad(
|
||||||
noOpenServerError: true,
|
() => {
|
||||||
loading: false,
|
browserHistory.push('/' + team.name + '/channels/town-square');
|
||||||
serverError: (
|
}
|
||||||
<FormattedMessage
|
);
|
||||||
id='signup_user_completed.invalid_invite'
|
},
|
||||||
defaultMessage='The invite link was invalid. Please speak with your Administrator to receive an invitation.'
|
(err) => {
|
||||||
/>
|
this.setState({ // eslint-disable-line react/no-did-mount-set-state
|
||||||
)
|
serverError: err.message
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inviteId) {
|
||||||
|
Client.getInviteInfo(
|
||||||
|
inviteId,
|
||||||
|
(inviteData) => {
|
||||||
|
if (!inviteData) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
);
|
|
||||||
}
|
this.setState({ // eslint-disable-line react/no-did-mount-set-state
|
||||||
} else if (UserStore.getCurrentUser()) {
|
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');
|
browserHistory.push('/select_team');
|
||||||
} else {
|
|
||||||
this.setState({ // eslint-disable-line react/no-did-mount-set-state
|
|
||||||
loading: false
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user