deactivateAccount method
- AuthenticationData? auth,
- bool? erase,
- String? idServer,
Deactivate the user's account, removing all ability for the user to login again.
This API endpoint uses the User-Interactive Authentication API.
An access token should be submitted to this endpoint if the client has an active session.
The homeserver may change the flows available depending on whether a valid access token is provided.
Unlike other endpoints, this endpoint does not take an id_access_token
parameter because the homeserver is expected to sign the request to the
identity server instead.
auth
Additional authentication information for the user-interactive authentication API.
erase
Whether the user would like their content to be erased as
much as possible from the server.
Erasure means that any users (or servers) which join the room after the erasure request are served redacted copies of the events sent by this account. Users which had visibility on those events prior to the erasure are still able to see unredacted copies. No redactions are sent and the erasure request is not shared over federation, so other servers might still serve unredacted copies.
The server should additionally erase any non-event data associated with the user, such as account data and contact 3PIDs.
Defaults to false
if not present.
idServer
The identity server to unbind all of the user's 3PIDs from.
If not provided, the homeserver MUST use the id_server
that was originally use to bind each identifier. If the
homeserver does not know which id_server
that was,
it must return an id_server_unbind_result
of
no-support
.
returns id_server_unbind_result
:
An indicator as to whether or not the homeserver was able to unbind
the user's 3PIDs from the identity server(s). success
indicates
that all identifiers have been unbound from the identity server while
no-support
indicates that one or more identifiers failed to unbind
due to the identity server refusing the request or the homeserver
being unable to determine an identity server to unbind from. This
must be success
if the homeserver has no identifiers to unbind
for the user.
Implementation
Future<IdServerUnbindResult> deactivateAccount(
{AuthenticationData? auth, bool? erase, String? idServer}) async {
final requestUri = Uri(path: '_matrix/client/v3/account/deactivate');
final request = Request('POST', baseUri!.resolveUri(requestUri));
if (bearerToken != null) {
request.headers['authorization'] = 'Bearer ${bearerToken!}';
}
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(jsonEncode({
if (auth != null) 'auth': auth.toJson(),
if (erase != null) 'erase': erase,
if (idServer != null) 'id_server': idServer,
}));
final response = await httpClient.send(request);
final responseBody = await response.stream.toBytes();
if (response.statusCode != 200) unexpectedResponse(response, responseBody);
final responseString = utf8.decode(responseBody);
final json = jsonDecode(responseString);
return IdServerUnbindResult.values
.fromString(json['id_server_unbind_result'] as String)!;
}