diff --git a/refilc/lib/api/providers/sync.dart b/refilc/lib/api/providers/sync.dart index 7820b59..e5c3c33 100644 --- a/refilc/lib/api/providers/sync.dart +++ b/refilc/lib/api/providers/sync.dart @@ -84,20 +84,20 @@ Future syncAll(BuildContext context) async { return; } - //if (user.user!.accessTokenExpire.isBefore(DateTime.now())) { - // String authRes = await Provider.of(context, listen: false) - // .refreshLogin() ?? - // ''; - // if (authRes != 'success') { - // if (kDebugMode) print('ERROR: failed to refresh login'); - // lock = false; - // return Future.value(); - // } else { - // if (kDebugMode) print('INFO: access token refreshed'); - // } - //} else { - // if (kDebugMode) print('INFO: access token is not expired'); - //} + if (user.user!.accessTokenExpire.isBefore(DateTime.now())) { + String authRes = await Provider.of(context, listen: false) + .refreshLogin() ?? + ''; + if (authRes != 'success') { + if (kDebugMode) print('ERROR: failed to refresh login'); + / lock = false; + / return Future.value(); + / } else { + / if (kDebugMode) print('INFO: access token refreshed'); + / } + } else { + if (kDebugMode) print('INFO: access token is not expired'); + } }()), syncStatus(Provider.of(context, listen: false).fetch()), diff --git a/refilc_kreta_api/lib/client/client.dart b/refilc_kreta_api/lib/client/client.dart index 0c6ebc4..1291f1a 100644 --- a/refilc_kreta_api/lib/client/client.dart +++ b/refilc_kreta_api/lib/client/client.dart @@ -91,7 +91,7 @@ class KretaClient { headerMap.remove("authorization"); print("DEBUG: 401 error, refreshing login"); print("DEBUG: 401 error, URL: $url"); - await refreshLogin(); + //await refreshLogin(); } else { break; } @@ -160,7 +160,7 @@ class KretaClient { res = await client.post(Uri.parse(url), headers: headerMap, body: body); if (res.statusCode == 401) { - await refreshLogin(); + //await refreshLogin(); headerMap.remove("authorization"); } else { break; @@ -234,7 +234,7 @@ class KretaClient { if (res.statusCode == 401) { headerMap.remove("authorization"); - await refreshLogin(); + //await refreshLogin(); } else { break; }