Improve terms handling for 3PID state gathering

This changes the 3PID state gathering (used in Settings) to ignore terms errors
(no modals will be shown) on the assumption that other UX handles this case.
pull/21833/head
J. Ryan Stinnett 2019-09-11 13:36:10 +01:00
parent f04c347df7
commit 0b7995dc11
3 changed files with 23 additions and 18 deletions

View File

@ -65,7 +65,7 @@ export default class IdentityAuthClient {
}
// Returns a promise that resolves to the access_token string from the IS
async getAccessToken(check=true) {
async getAccessToken({ check = true } = {}) {
if (!this.authEnabled) {
// The current IS doesn't support authentication
return null;

View File

@ -26,10 +26,9 @@ export async function getThreepidsWithBindStatus(client, filterMedium) {
// Check bind status assuming we have an IS and terms are agreed
if (threepids.length > 0 && client.getIdentityServerUrl()) {
// TODO: Handle terms agreement
// See https://github.com/vector-im/riot-web/issues/10522
try {
const authClient = new IdentityAuthClient();
const identityAccessToken = await authClient.getAccessToken();
const identityAccessToken = await authClient.getAccessToken({ check: false });
// Restructure for lookup query
const query = threepids.map(({ medium, address }) => [medium, address]);
@ -47,6 +46,12 @@ export async function getThreepidsWithBindStatus(client, filterMedium) {
if (!threepid) continue;
threepid.bound = true;
}
} catch (e) {
// Ignore terms errors here and assume other flows handle this
if (!(e.errcode === "M_TERMS_NOT_SIGNED")) {
throw e;
}
}
}
return threepids;

View File

@ -110,7 +110,7 @@ export default class GeneralUserSettingsTab extends React.Component {
// By starting the terms flow we get the logic for checking which terms the user has signed
// for free. So we might as well use that for our own purposes.
const authClient = new IdentityAuthClient();
const idAccessToken = await authClient.getAccessToken(/*check=*/false);
const idAccessToken = await authClient.getAccessToken({ check: false });
startTermsFlow([new Service(
SERVICE_TYPES.IS,
MatrixClientPeg.get().getIdentityServerUrl(),