You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Implement API for username availability (#432)
Requires synapse with https://github.com/matrix-org/synapse/pull/2183, https://github.com/matrix-org/synapse/pull/2209 and https://github.com/matrix-org/synapse/pull/2213
This commit is contained in:
@@ -120,6 +120,20 @@ MatrixBaseApis.prototype.makeTxnId = function() {
|
||||
// Registration/Login operations
|
||||
// =============================
|
||||
|
||||
/**
|
||||
* Check whether a username is available prior to registration. An error response
|
||||
* indicates an invalid/unavailable username.
|
||||
* @param {string} username The username to check the availability of.
|
||||
* @return {module:client.Promise} Resolves: to `true`.
|
||||
*/
|
||||
MatrixBaseApis.prototype.isUsernameAvailable = function(username) {
|
||||
return this._http.authedRequest(
|
||||
undefined, "GET", '/register/available', { username: username },
|
||||
).then((response) => {
|
||||
return response.available;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} username
|
||||
* @param {string} password
|
||||
|
||||
Reference in New Issue
Block a user