logout method

Future<void> logout()

Implementation

Future<void> logout() async {
  if (await isAuthenticated() == false) {
    throw Exception("user is currently not logged in");
  }
  try {
    // block current access token
    HeraRequest req = HeraRequest();
    req.cloudToken = await _authorize.getAccessToken();
    req.tokenPointer = await getAccessToken();
    req.namespace = namespace;
    grpcUserClient.blockToken(req);
    // block current refresh token
    req.tokenPointer = await _getRefreshToken();
    grpcUserClient.blockToken(req);
    // remove from secure storage
    _secureStorage.delete(key: _accessTokenKey);
    _secureStorage.delete(key: _refreshTokenKey);
    _secureStorage.delete(key: _currentUserKey);
    _currentUser = User();
    _accessToken = "";
    _refreshToken = "";
  } catch (e) {
    if (debug == true) print("could not logout user: " + e.toString());
    rethrow;
  }
}