Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions matrix_client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,35 +125,38 @@ def sync(self, since=None, timeout_ms=30000, filter=None,
def validate_certificate(self, valid):
self.validate_cert = valid

def register(self, content=None, kind='user'):
def register(self, auth_body=None, kind="user", bind_email=None,
username=None, password=None, device_id=None,
initial_device_display_name=None, inhibit_login=None):
"""Performs /register.

Args:
content (dict): The request payload.

| Should be specified for all non-guest registrations.

| username (string): The local part of the desired Matrix ID.
| If omitted, the homeserver MUST generate a Matrix ID local part.

| bind_email (boolean): If true, the server binds the email used for
| authentication to the Matrix ID with the ID Server.
| *Email Registration not currently supported*

| password (string): Required. The desired password for the account.

| auth (dict): Authentication Data
| session (string): The value of the session key given by the
| homeserver.

| type (string): Required. The login type that the client is
| attempting to complete. "m.login.dummy" is the only
| non-interactive type.

kind (str): Specify kind="guest" to register as guest.
auth_body (dict): Authentication Params.
kind (str): Specify kind of account to register. Can be 'guest' or 'user'.
bind_email (bool): Whether to use email in registration and authentication.
username (str): The localpart of a Matrix ID.
password (str): The desired password of the account.
device_id (str): ID of the client device.
initial_device_display_name (str): Display name to be assigned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list lacks inhibit_login.

inhibit_login (bool): Whether to login after registration. Defaults to false.
"""
if content is None:
content = {}
content = {}
content["kind"] = kind
if auth_body:
content["auth"] = auth_body
if username:
content["username"] = username
if password:
content["password"] = password
if device_id:
content["device_id"] = device_id
if initial_device_display_name:
content["initial_device_display_name"] = \
initial_device_display_name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add similar statements to above for bind_email and inhibit_login.

if bind_email:
content["bind_email"] = bind_email
if inhibit_login:
content["inhibit_login"] = inhibit_login
return self._send(
"POST",
"/register",
Expand Down
11 changes: 5 additions & 6 deletions matrix_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def register_as_guest(self):
Raises:
MatrixRequestError
"""
response = self.api.register(kind='guest')
response = self.api.register(auth_body=None, kind='guest')
return self._post_registration(response)

def register_with_password(self, username, password):
Expand All @@ -201,11 +201,10 @@ def register_with_password(self, username, password):
MatrixRequestError
"""
response = self.api.register(
{
"auth": {"type": "m.login.dummy"},
"username": username,
"password": password
}
auth_body={"type": "m.login.dummy"},
kind='user',
username=username,
password=password,
)
return self._post_registration(response)

Expand Down