You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Add register-specific request token endpoint
As per https://github.com/matrix-org/matrix-doc/pull/343
This commit is contained in:
@@ -23,6 +23,7 @@ var PushProcessor = require('./pushprocessor');
|
||||
*/
|
||||
var EventEmitter = require("events").EventEmitter;
|
||||
var q = require("q");
|
||||
var url = require('url');
|
||||
|
||||
var httpApi = require("./http-api");
|
||||
var MatrixEvent = require("./models/event").MatrixEvent;
|
||||
@@ -2784,6 +2785,42 @@ MatrixClient.prototype.register = function(username, password,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Requests an email verification token for the purposes of registration.
|
||||
* This API proxies the Identity Server /validate/email/requestToken API,
|
||||
* adding registration-specific behaviour. Specifically, an account with
|
||||
* the given email address already exists, it will either send an email
|
||||
* to the address informing them of this or return M_THREEPID_IN_USE
|
||||
* (which one is up to the Home Server).
|
||||
*
|
||||
* requestEmailToken calls the equivalent API directly on the ID server,
|
||||
* therefore bypassing the registration-specific logic.
|
||||
*
|
||||
* @param {string} email
|
||||
* @param {string} clientSecret
|
||||
* @param {string} sendAttempt
|
||||
* @param {string} nextLink Optional
|
||||
* @param {module:client.callback} callback Optional.
|
||||
* @return {module:client.Promise} Resolves: TODO
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixClient.prototype.requestRegisterEmailToken = function(email, clientSecret,
|
||||
sendAttempt, nextLink, callback) {
|
||||
var id_server_url = url.parse(this.idBaseUrl);
|
||||
|
||||
var params = {
|
||||
client_secret: clientSecret,
|
||||
email: email,
|
||||
send_attempt: sendAttempt,
|
||||
next_link: nextLink,
|
||||
id_server: id_server_url.host,
|
||||
};
|
||||
return this._http.request(
|
||||
callback, "POST", "/register/email/requestToken", undefined,
|
||||
params
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} user
|
||||
* @param {string} password
|
||||
@@ -3665,6 +3702,11 @@ MatrixClient.prototype.getEventMapper = function() {
|
||||
// ==========================
|
||||
|
||||
/**
|
||||
* Requests an email verification token directly from an Identity Server.
|
||||
*
|
||||
* Note that the Home Server offers APIs to proxy this API for specific
|
||||
* situations, allowing for better feedback to the user.
|
||||
*
|
||||
* @param {string} email
|
||||
* @param {string} clientSecret
|
||||
* @param {string} sendAttempt
|
||||
|
||||
Reference in New Issue
Block a user