logout static method

Future<void> logout()

Implementation

static Future<void> logout() async {
  if (await isAuthenticated() == false) {
    throw Exception("user is currently not logged in");
  }
  try {
    String accessToken = await getAccessToken();
    _secureStorage.delete(key: _accessTokenKey);
    _secureStorage.delete(key: _refreshTokenKey);
    _currentUser = User();
    _accessToken = "";
    _refreshToken = "";
    HeraRequest req = HeraRequest()
      ..namespace = _namespace
      ..authToken = AuthToken(userToken: accessToken)
      ..token = (Token()..accessToken = accessToken);
    await _heraClient.logout(req);
    onLogout();
  } catch (e) {
    if (kDebugMode) {
      print("could not logout user: $e");
    }
    rethrow;
  }
}