logoutCurrentUser static method
Logs out the current user.
- Parameters:
manager
: An optionalMBManager
used to make calls instead ofMBManager.shared
.
- Returns a Future that completes when the user is logged out correctly.
Implementation
static Future<void> logoutCurrentUser({
MBManager? manager,
}) async {
MBManager mbManager = manager ?? MBManager.shared;
String apiName = 'api/logout';
var uri = Uri.https(mbManager.endpoint, apiName);
var requestBody = json.encode(await mbManager.defaultParameters());
Map<String, String> headers =
await mbManager.headers(contentTypeJson: true);
http.Response response = await http.post(
uri,
headers: headers,
body: requestBody,
);
MBManager.checkResponse(response.body, checkBody: false);
await _setUserLoggedOut();
}