isAuthenticated static method

Future<bool> isAuthenticated()

Implementation

static Future<bool> isAuthenticated() async {
  String accessToken = await getAccessToken();
  bool _isAuthenticated = accessToken.isNotEmpty;
  print(_isAuthenticated);
  if (_isAuthenticated) {
    try {
      HeraResponse response = await _heraClient.validateToken(HeraRequest(
        token: Token()..accessToken = accessToken,
        accessToken: accessToken,
      ));
      response = await _heraClient.get(HeraRequest(
        accessToken: accessToken,
      ));
      _setCurrentUser(response.user);
    } catch (e) {
      print(e.toString());
      _isAuthenticated = false;
      _setAccessToken("");
      _setRefreshToken("");
    }
  }
  return _isAuthenticated;
}