checkUserAuthentication method

Future<String?> checkUserAuthentication(
  1. {bool notify = true}
)

Implementation

Future<String?> checkUserAuthentication({bool notify = true}) async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  userIdentifier = prefs.getString("user_identifier");
  var userAccessToken = prefs.getString("access_token");
  if (userAccessToken != null && userAccessToken.isNotEmpty) {
    AccessToken? response = AccessToken.fromJson(jsonDecode(userAccessToken));
    if (response != null) {
      updateClientsWithUserAccessToken(response, notify: notify);
      UserApi userApi = UserApi();
      await userApi.getMyProfile().then((profileResponse) {
        currentUser = profileResponse.data;
      }).catchError((error) {
        if (error is ApiException) {
          if (error.code == 401) {
            expireSession();
          }
        }
        if (kDebugMode) {
          print(error);
        }
      });
    }
  }
  return Future.value(userIdentifier);
}