diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b497e9..bd460b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [4.0.4] - 2024-11-27 + +* Fix auth issue +* Dependency updates + ## [4.0.3] - 2024-11-25 * Dependency updates diff --git a/README.md b/README.md index feff1ee..5649623 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ In your flutter project add the dependency: ``` dart dependencies: ... - wp_json_api: ^4.0.3 + wp_json_api: ^4.0.4 ``` ### Usage example # diff --git a/example/pubspec.lock b/example/pubspec.lock index b0e61b3..9254c24 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -400,10 +400,9 @@ packages: nylo_support: dependency: transitive description: - name: nylo_support - sha256: "7707ecaba8cee2defec4e0609d0e73e6b08a52b3432f6c5a373de6581fe973a9" - url: "https://pub.dev" - source: hosted + path: "/Users/anthony/StudioProjects/support" + relative: false + source: path version: "6.6.0" path: dependency: transitive @@ -784,7 +783,7 @@ packages: path: ".." relative: true source: path - version: "4.0.3" + version: "4.0.4" xdg_directories: dependency: transitive description: diff --git a/lib/wp_json_api.dart b/lib/wp_json_api.dart index 947dd64..4cc4cd0 100644 --- a/lib/wp_json_api.dart +++ b/lib/wp_json_api.dart @@ -17,12 +17,13 @@ library wp_json_api; import 'package:nylo_support/helpers/auth.dart'; import 'package:nylo_support/local_storage/local_storage.dart'; +import 'package:nylo_support/nylo.dart'; import '/helpers/typedefs.dart'; import '/models/wp_user.dart'; import '/networking/network_manager.dart'; /// The version of the wp_json_api -String _wpJsonAPIVersion = "4.0.3"; +String _wpJsonAPIVersion = "4.0.4"; /// The base class to initialize and use WPJsonAPI class WPJsonAPI { @@ -51,10 +52,17 @@ class WPJsonAPI { init( {required String baseUrl, String wpJsonPath = '/wp-json', - bool shouldDebug = true}) { + bool shouldDebug = true, + bool nylo = false}) { _setBaseApi(baseUrl: baseUrl); _setApiPath(path: wpJsonPath); _setShouldDebug(value: shouldDebug); + + // nylo setup + if (!nylo) { + Nylo.package(); + Nylo.instance.addAuthKey(storageKey()); + } } /// Login a user with the [WpUser] @@ -70,21 +78,14 @@ class WPJsonAPI { /// Authenticate a user if they are logged in static wpAuth() async { final data = await storageRead(WPJsonAPI.storageKey()); - if (data != null) { - return WpUser.fromJson(data); - } - return null; + if (data != null) return null; + return WpUser.fromJson(data); } /// Check if a user is logged in static Future wpUserLoggedIn() async { WpUser? _wpUser = await wpUser(); - if (_wpUser == null) { - return false; - } - if (_wpUser.token == null) { - return false; - } + if (_wpUser?.token == null) return false; return true; } diff --git a/pubspec.lock b/pubspec.lock index c758788..50dd876 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -400,10 +400,9 @@ packages: nylo_support: dependency: "direct main" description: - name: nylo_support - sha256: "7707ecaba8cee2defec4e0609d0e73e6b08a52b3432f6c5a373de6581fe973a9" - url: "https://pub.dev" - source: hosted + path: "/Users/anthony/StudioProjects/support" + relative: false + source: path version: "6.6.0" path: dependency: transitive diff --git a/pubspec.yaml b/pubspec.yaml index 9715760..280efd6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: wp_json_api description: WordPress and WooCommerce JSON API for Flutter Mobile. API allows you to login, register new users, get users info and more. -version: 4.0.3 +version: 4.0.4 homepage: https://woosignal.com repository: https://github.com/woosignal/wp-json-api-flutter issue_tracker: https://github.com/woosignal/wp-json-api-flutter/issues @@ -12,7 +12,7 @@ environment: dependencies: dio: ^5.7.0 - nylo_support: ^6.6.0 + nylo_support: ^6.7.0 flutter: sdk: flutter collection: ^1.17.0