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
docs: registerGuest
This commit is contained in:
@@ -246,16 +246,30 @@ MatrixBaseApis.prototype.register = function(
|
||||
|
||||
/**
|
||||
* Register a guest account.
|
||||
* This method returns the auth info needed to create a new authenticated client,
|
||||
* Remember to call `setGuest(true)` on the (guest-)authenticated client, e.g:
|
||||
* ```javascript
|
||||
* const tmpClient = await sdk.createClient(MATRIX_INSTANCE);
|
||||
* const { user_id, device_id, access_token } = tmpClient.registerGuest();
|
||||
* const client = createClient({
|
||||
* baseUrl: MATRIX_INSTANCE,
|
||||
* accessToken: access_token,
|
||||
* userId: user_id,
|
||||
* deviceId: device_id,
|
||||
* })
|
||||
* client.setGuest(true);
|
||||
* ```
|
||||
*
|
||||
* @param {Object=} opts Registration options
|
||||
* @param {Object} opts.body JSON HTTP body to provide.
|
||||
* @param {module:client.callback} callback Optional.
|
||||
* @return {Promise} Resolves: TODO
|
||||
* @return {Promise} Resolves: JSON object that contains:
|
||||
* { user_id, device_id, access_token, home_server }
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixBaseApis.prototype.registerGuest = function(opts, callback) {
|
||||
opts = opts || {};
|
||||
opts.body = opts.body || {};
|
||||
this.setGuest(true);
|
||||
return this.registerRequest(opts.body, "guest", callback);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user