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
    dart_blocks.UserRequest req = dart_blocks.UserRequest();
    req.cloudToken = await _authorize.getAccessToken();
    req.tokenPointer = await getAccessToken();
    _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 = dart_blocks.User();
    _accessToken = "";
    _refreshToken = "";
  } catch (e) {
    if (debug == true) print("could not logout user: " + e.toString());
    rethrow;
  }
}