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
parent
f04c347df7
commit
0b7995dc11
|
@ -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;
|
||||
|
|
|
@ -26,26 +26,31 @@ 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
|
||||
const authClient = new IdentityAuthClient();
|
||||
const identityAccessToken = await authClient.getAccessToken();
|
||||
try {
|
||||
const authClient = new IdentityAuthClient();
|
||||
const identityAccessToken = await authClient.getAccessToken({ check: false });
|
||||
|
||||
// Restructure for lookup query
|
||||
const query = threepids.map(({ medium, address }) => [medium, address]);
|
||||
const lookupResults = await client.bulkLookupThreePids(query, identityAccessToken);
|
||||
// Restructure for lookup query
|
||||
const query = threepids.map(({ medium, address }) => [medium, address]);
|
||||
const lookupResults = await client.bulkLookupThreePids(query, identityAccessToken);
|
||||
|
||||
// Record which are already bound
|
||||
for (const [medium, address, mxid] of lookupResults.threepids) {
|
||||
if (mxid !== userId) {
|
||||
continue;
|
||||
// Record which are already bound
|
||||
for (const [medium, address, mxid] of lookupResults.threepids) {
|
||||
if (mxid !== userId) {
|
||||
continue;
|
||||
}
|
||||
if (filterMedium && medium !== filterMedium) {
|
||||
continue;
|
||||
}
|
||||
const threepid = threepids.find(e => e.medium === medium && e.address === address);
|
||||
if (!threepid) continue;
|
||||
threepid.bound = true;
|
||||
}
|
||||
if (filterMedium && medium !== filterMedium) {
|
||||
continue;
|
||||
} catch (e) {
|
||||
// Ignore terms errors here and assume other flows handle this
|
||||
if (!(e.errcode === "M_TERMS_NOT_SIGNED")) {
|
||||
throw e;
|
||||
}
|
||||
const threepid = threepids.find(e => e.medium === medium && e.address === address);
|
||||
if (!threepid) continue;
|
||||
threepid.bound = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in New Issue