mirror of https://github.com/vector-im/riot-web
Show terms modal when inviting by email
This invokes the terms modal flow when inviting someone by email. Entering an email triggers a lookup to the IS, and if it has terms you need to agree to, then a separate modal is shown to complete this activity. You then come back to invite screen after agreeing to the terms. Fixes https://github.com/vector-im/riot-web/issues/10093pull/21833/head
parent
7bb1e503cb
commit
348f6f971a
|
@ -14,7 +14,10 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as Matrix from 'matrix-js-sdk';
|
||||||
|
|
||||||
import MatrixClientPeg from './MatrixClientPeg';
|
import MatrixClientPeg from './MatrixClientPeg';
|
||||||
|
import { Service, startTermsFlow } from './Terms';
|
||||||
|
|
||||||
export default class IdentityAuthClient {
|
export default class IdentityAuthClient {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -57,7 +60,20 @@ export default class IdentityAuthClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
async _checkToken(token) {
|
async _checkToken(token) {
|
||||||
|
try {
|
||||||
await MatrixClientPeg.get().getIdentityAccount(token);
|
await MatrixClientPeg.get().getIdentityAccount(token);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.errcode === "M_TERMS_NOT_SIGNED") {
|
||||||
|
console.log("Identity Server requires new terms to be agreed to");
|
||||||
|
await startTermsFlow([new Service(
|
||||||
|
Matrix.SERVICE_TYPES.IS,
|
||||||
|
MatrixClientPeg.get().idBaseUrl,
|
||||||
|
token,
|
||||||
|
)]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
// We should ensure the token in `localStorage` is cleared
|
// We should ensure the token in `localStorage` is cleared
|
||||||
// appropriately. We already clear storage on sign out, but we'll need
|
// appropriately. We already clear storage on sign out, but we'll need
|
||||||
|
|
Loading…
Reference in New Issue