HostingSignupDialog now returns requested data in one message

pull/21833/head
Jason Robinson 2020-12-11 16:03:18 +02:00
parent 31c7c05f2e
commit 518c4c5dc9
1 changed files with 10 additions and 18 deletions

View File

@ -20,6 +20,7 @@ import Modal from "../../../Modal";
import SdkConfig from "../../../SdkConfig"; import SdkConfig from "../../../SdkConfig";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
import { MatrixClientPeg } from "../../../MatrixClientPeg"; import { MatrixClientPeg } from "../../../MatrixClientPeg";
import { OwnProfileStore } from "../../../stores/OwnProfileStore";
interface IProps { interface IProps {
requestClose(): void; requestClose(): void;
@ -51,7 +52,7 @@ export default class HostingSignupDialog extends React.PureComponent<IProps, ISt
return; return;
} }
switch (message.data.action) { switch (message.data.action) {
case 'account_credentials_request': case 'element_pro_account_details_request':
// noinspection JSIgnoredPromiseFromCall // noinspection JSIgnoredPromiseFromCall
this.sendAccountDetails(); this.sendAccountDetails();
break; break;
@ -62,10 +63,6 @@ export default class HostingSignupDialog extends React.PureComponent<IProps, ISt
completed: true, completed: true,
}); });
break; break;
case 'openid_credentials_request':
// noinspection JSIgnoredPromiseFromCall
this.fetchOpenIDToken();
break;
case 'close_dialog': case 'close_dialog':
this.onFinished(true); this.onFinished(true);
break; break;
@ -98,25 +95,20 @@ export default class HostingSignupDialog extends React.PureComponent<IProps, ISt
) )
} }
private async fetchOpenIDToken() { private async sendAccountDetails() {
const token = await MatrixClientPeg.get().getOpenIdToken(); const openIdToken = await MatrixClientPeg.get().getOpenIdToken();
if (token && token.access_token) { if (!openIdToken || !openIdToken.access_token) {
this.sendMessage({
action: 'openid_credentials',
tokenData: token,
});
} else {
this.setState({ this.setState({
error: _t("Failed to connect to your homeserver. Please close this dialog and try again."), error: _t("Failed to connect to your homeserver. Please close this dialog and try again."),
}); });
return;
} }
}
private async sendAccountDetails() {
this.sendMessage({ this.sendMessage({
action: 'account_credentials', action: 'element_pro_account_details',
credentials: { account: {
accessToken: await MatrixClientPeg.get().getAccessToken(), accessToken: await MatrixClientPeg.get().getAccessToken(),
name: OwnProfileStore.instance.displayName,
openIdToken: openIdToken.access_token,
serverName: await MatrixClientPeg.get().getDomain(), serverName: await MatrixClientPeg.get().getDomain(),
userLocalpart: await MatrixClientPeg.get().getUserIdLocalpart(), userLocalpart: await MatrixClientPeg.get().getUserIdLocalpart(),
}, },