Method: MatrixSdk::Client#register_with_password

Defined in:
lib/matrix_sdk/client.rb

#register_with_password(username, password, full_state: true, **params) ⇒ Object

Raises:

  • (ArgumentError)


143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/matrix_sdk/client.rb', line 143

def register_with_password(username, password, full_state: true, **params)
  username = username.to_s unless username.is_a?(String)
  password = password.to_s unless password.is_a?(String)

  raise ArgumentError, "Username can't be nil or empty" if username.nil? || username.empty?
  raise ArgumentError, "Password can't be nil or empty" if password.nil? || username.empty?

  data = api.register(auth: { type: 'm.login.dummy' }, username: username, password: password)
  post_authentication(data)

  return if params[:no_sync]

  sync full_state: full_state,
       allow_sync_retry: params.fetch(:allow_sync_retry, nil)
end