Extract separate add / bind methods on AddThreepid
This commit is contained in:
parent
99b804d567
commit
9a1305bf4a
6 changed files with 45 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
Copyright 2016 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -33,14 +34,12 @@ export default class AddThreepid {
|
|||
}
|
||||
|
||||
/**
|
||||
* Attempt to add an email threepid. This will trigger a side-effect of
|
||||
* sending an email to the provided email address.
|
||||
* Attempt to add an email threepid to the homeserver.
|
||||
* This will trigger a side-effect of sending an email to the provided email address.
|
||||
* @param {string} emailAddress The email address to add
|
||||
* @param {boolean} bind If True, bind this email to this mxid on the Identity Server
|
||||
* @return {Promise} Resolves when the email has been sent. Then call checkEmailLinkClicked().
|
||||
*/
|
||||
addEmailAddress(emailAddress, bind) {
|
||||
this.bind = bind;
|
||||
addEmailAddress(emailAddress) {
|
||||
return MatrixClientPeg.get().requestAdd3pidEmailToken(emailAddress, this.clientSecret, 1).then((res) => {
|
||||
this.sessionId = res.sid;
|
||||
return res;
|
||||
|
@ -55,15 +54,25 @@ export default class AddThreepid {
|
|||
}
|
||||
|
||||
/**
|
||||
* Attempt to add a msisdn threepid. This will trigger a side-effect of
|
||||
* sending a test message to the provided phone number.
|
||||
* Attempt to bind an email threepid on the identity server via the homeserver.
|
||||
* This will trigger a side-effect of sending an email to the provided email address.
|
||||
* @param {string} emailAddress The email address to add
|
||||
* @return {Promise} Resolves when the email has been sent. Then call checkEmailLinkClicked().
|
||||
*/
|
||||
bindEmailAddress(emailAddress) {
|
||||
this.bind = true;
|
||||
// TODO: Actually use a different API here
|
||||
return this.addEmailAddress(emailAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to add a MSISDN threepid to the homeserver.
|
||||
* This will trigger a side-effect of sending an SMS to the provided phone number.
|
||||
* @param {string} phoneCountry The ISO 2 letter code of the country to resolve phoneNumber in
|
||||
* @param {string} phoneNumber The national or international formatted phone number to add
|
||||
* @param {boolean} bind If True, bind this phone number to this mxid on the Identity Server
|
||||
* @return {Promise} Resolves when the text message has been sent. Then call haveMsisdnToken().
|
||||
*/
|
||||
addMsisdn(phoneCountry, phoneNumber, bind) {
|
||||
this.bind = bind;
|
||||
addMsisdn(phoneCountry, phoneNumber) {
|
||||
return MatrixClientPeg.get().requestAdd3pidMsisdnToken(
|
||||
phoneCountry, phoneNumber, this.clientSecret, 1,
|
||||
).then((res) => {
|
||||
|
@ -79,6 +88,19 @@ export default class AddThreepid {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to bind a MSISDN threepid on the identity server via the homeserver.
|
||||
* This will trigger a side-effect of sending an SMS to the provided phone number.
|
||||
* @param {string} phoneCountry The ISO 2 letter code of the country to resolve phoneNumber in
|
||||
* @param {string} phoneNumber The national or international formatted phone number to add
|
||||
* @return {Promise} Resolves when the text message has been sent. Then call haveMsisdnToken().
|
||||
*/
|
||||
bindMsisdn(phoneCountry, phoneNumber) {
|
||||
this.bind = true;
|
||||
// TODO: Actually use a different API here
|
||||
return this.addMsisdn(phoneCountry, phoneNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the email link has been clicked by attempting to add the threepid
|
||||
* @return {Promise} Resolves if the email address was added. Rejects with an object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue