Use alternate MSISDN submit URL when returned by HS
This changes MSISDN token submission to send to an arbitrary URL (instead of the current IS) when the HS provides such a URL. Fixes https://github.com/vector-im/riot-web/issues/10923
This commit is contained in:
parent
351a3ebd67
commit
e98b753c21
1 changed files with 20 additions and 6 deletions
|
@ -35,6 +35,8 @@ import IdentityAuthClient from './IdentityAuthClient';
|
||||||
export default class AddThreepid {
|
export default class AddThreepid {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.clientSecret = MatrixClientPeg.get().generateClientSecret();
|
this.clientSecret = MatrixClientPeg.get().generateClientSecret();
|
||||||
|
this.sessionId = null;
|
||||||
|
this.submitUrl = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,6 +103,7 @@ export default class AddThreepid {
|
||||||
phoneCountry, phoneNumber, this.clientSecret, 1,
|
phoneCountry, phoneNumber, this.clientSecret, 1,
|
||||||
).then((res) => {
|
).then((res) => {
|
||||||
this.sessionId = res.sid;
|
this.sessionId = res.sid;
|
||||||
|
this.submitUrl = res.submit_url;
|
||||||
return res;
|
return res;
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err.errcode === 'M_THREEPID_IN_USE') {
|
if (err.errcode === 'M_THREEPID_IN_USE') {
|
||||||
|
@ -198,12 +201,23 @@ export default class AddThreepid {
|
||||||
async haveMsisdnToken(msisdnToken) {
|
async haveMsisdnToken(msisdnToken) {
|
||||||
const authClient = new IdentityAuthClient();
|
const authClient = new IdentityAuthClient();
|
||||||
const identityAccessToken = await authClient.getAccessToken();
|
const identityAccessToken = await authClient.getAccessToken();
|
||||||
const result = await MatrixClientPeg.get().submitMsisdnToken(
|
|
||||||
|
let result;
|
||||||
|
if (this.submitUrl) {
|
||||||
|
result = await MatrixClientPeg.get().submitMsisdnTokenOtherUrl(
|
||||||
|
this.submitUrl,
|
||||||
|
this.sessionId,
|
||||||
|
this.clientSecret,
|
||||||
|
msisdnToken,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
result = await MatrixClientPeg.get().submitMsisdnToken(
|
||||||
this.sessionId,
|
this.sessionId,
|
||||||
this.clientSecret,
|
this.clientSecret,
|
||||||
msisdnToken,
|
msisdnToken,
|
||||||
identityAccessToken,
|
identityAccessToken,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
if (result.errcode) {
|
if (result.errcode) {
|
||||||
throw result;
|
throw result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue