- Fixed an issue with the `ArcaneAuthenticationService` where an exception would
  be thrown when attempting to access an authentication token while no
  `ArcaneAuthInterface` was registered.

Signed-off-by: Hans Kokx <hans.kokx@hackberry.se>
This commit is contained in:
Hans Kokx
2024-12-11 11:02:58 +01:00
parent bc0972cf32
commit adef2e01dd
3 changed files with 52 additions and 38 deletions
+38 -17
View File
@@ -1,6 +1,13 @@
## 1.1.7
- Fixed an issue with the `ArcaneAuthenticationService` where an exception would
be thrown when attempting to access an authentication token while no
`ArcaneAuthInterface` was registered.
## 1.1.6
- Updated logging feature to indicate the feature which was enabled or disabled within the log message, instead of only in the metadata
- Updated logging feature to indicate the feature which was enabled or disabled
within the log message, instead of only in the metadata.
## 1.1.5
@@ -12,15 +19,18 @@
## 1.1.3
- Arcane Auth no longer throws exceptions when log out fails, instead returning a `Result<void, String>`. This behavior matches the login method.
- Arcane Auth no longer throws exceptions when log out fails, instead returning
a `Result<void, String>`. This behavior matches the login method.
## 1.1.2
- Removed Flutter exception handling from `ArcaneLoggingService`, as this functionality should be defined by a users' interface.
- Removed Flutter exception handling from `ArcaneLoggingService`, as this
functionality should be defined by a users' interface.
### Migration
Add the following to your `ArcaneLoggingInterface`'s `init` method to replicate the previous behavior:
Add the following to your `ArcaneLoggingInterface`'s `init` method to replicate
the previous behavior:
```dart
// Handles unhandled Flutter errors by logging them.
@@ -54,9 +64,10 @@ PlatformDispatcher.instance.onError = (error, stack) {
## 1.1.1
- [BREAKING] Updated ArcaneAuthInterface to make the `resendVerificationCode`, `confirmSignup`, and `resetPassword` methods more versatile
- [BREAKING] Updated ArcaneAuthInterface to make the `resendVerificationCode`,
`confirmSignup`, and `resetPassword` methods more versatile
### Migration
Migration:
| Class | Migration path |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
@@ -66,9 +77,10 @@ PlatformDispatcher.instance.onError = (error, stack) {
## 1.1.0
- [BREAKING] Updated the authentication service and interface to be more versatile
- [BREAKING] Updated the authentication service and interface to be more
versatile
### Migration
Migration:
| Class | Migration path |
| ------------------- | -------------------------------------------------------------------------------------- |
@@ -85,7 +97,8 @@ PlatformDispatcher.instance.onError = (error, stack) {
## 1.0.6+1
- Migrated linting rules to new [arcane_analysis](https://pub.dev/packages/arcane_analysis) package.
- Migrated linting rules to new
[arcane_analysis](https://pub.dev/packages/arcane_analysis) package.
## 1.0.6
@@ -97,18 +110,22 @@ PlatformDispatcher.instance.onError = (error, stack) {
## 1.0.5+1
- Marked the `loginWithEmailAndPassword` method in ArcaneAuthenticationService as deprecated and updated example project
- Marked the `loginWithEmailAndPassword` method in `ArcaneAuthenticationService`
as deprecated and updated example project
## 1.0.5
- Added the ability to use a generic type for the login method in ArcaneAuthenticationService
- Added the ability to reset the ArcaneAuthenticationService, which will unregister the current interface and clear the authentication state
- Added the ability to use a generic type for the login method in
ArcaneAuthenticationService
- Added the ability to reset the ArcaneAuthenticationService, which will
unregister the current interface and clear the authentication state
- Removed unused testing tooling (e.g., `@visibleForTesting`) from the codebase
- Migration guide: Remove usages of `setMocked` in your tests
## 1.0.4
- Resolved an issue with authentication using the ArcaneAuthenticationService when logging in with an email and password
- Resolved an issue with authentication using the ArcaneAuthenticationService
when logging in with an email and password
## 1.0.3+1
@@ -116,11 +133,15 @@ PlatformDispatcher.instance.onError = (error, stack) {
## 1.0.3
- Added the ability to switch back to the normal environment from the debug environment in ArcaneEnvironment
- (breaking) Made the optional `onLoggedOut` callback a Future instead of a void function in ArcaneAuthenticationService
- Added additional error handling to the login method in ArcaneAuthenticationService
- Added the ability to switch back to the normal environment from the debug
environment in ArcaneEnvironment
- (breaking) Made the optional `onLoggedOut` callback a Future instead of a void
function in ArcaneAuthenticationService
- Added additional error handling to the login method in
ArcaneAuthenticationService
- Added support for following the system's theme in ArcaneTheme
- Removed the BuildContext parameter from the `switchTheme` method in ArcaneTheme
- Removed the BuildContext parameter from the `switchTheme` method in
ArcaneTheme
## 1.0.2
@@ -35,13 +35,7 @@ class ArcaneAuthenticationService extends ArcaneService {
/// Provides direct access to the registered `ArcaneAuthInterface`, if one has
/// been registered.
ArcaneAuthInterface get authInterface {
assert(
_authInterface != null,
"No ArcaneAuthInterface has been registered",
);
return _authInterface!;
}
ArcaneAuthInterface? get authInterface => _authInterface;
/// A shortcut to `status != AuthenticationStatus.unauthenticated`.
bool get isAuthenticated => status != AuthenticationStatus.unauthenticated;
@@ -53,12 +47,12 @@ class ArcaneAuthenticationService extends ArcaneService {
/// provides one. This token is often used in the headers of HTTP requests
/// to the backend API.
Future<String?> get accessToken =>
authInterface.accessToken ?? Future.value("");
authInterface?.accessToken ?? Future.value("");
/// Returns a JWT refresh token if the registered `ArcaneAuthInterface`
/// provides one.
Future<String?> get refreshToken =>
authInterface.refreshToken ?? Future.value("");
authInterface?.refreshToken ?? Future.value("");
/// Removes any registered `ArcaneAuthInterface` and resets all values to
/// default.
@@ -158,14 +152,13 @@ class ArcaneAuthenticationService extends ArcaneService {
Future<Result<void, String>> logOut({
Future<void> Function()? onLoggedOut,
}) async {
if (_authInterface == null) {
return Result.error("No ArcaneAuthInterface has been registered");
}
if (!isAuthenticated) Result.error("User is not authenticated.");
assert(
_authInterface != null,
"No ArcaneAuthInterface has been registered",
);
final Result<void, String> loggedOut = await authInterface.logout();
final Result<void, String> loggedOut = await authInterface!.logout();
if (loggedOut.isSuccess) {
setUnauthenticated();
@@ -184,7 +177,7 @@ class ArcaneAuthenticationService extends ArcaneService {
return Result.error("No ArcaneAuthInterface has been registered");
}
final Result<void, String> result = await authInterface.login(
final Result<void, String> result = await authInterface!.login(
input: input,
);
@@ -206,7 +199,7 @@ class ArcaneAuthenticationService extends ArcaneService {
return Result.error("No ArcaneAuthInterface has been registered");
}
final Result<SignUpStep, String>? result = await authInterface.register(
final Result<SignUpStep, String>? result = await authInterface!.register(
input: input,
);
@@ -229,7 +222,7 @@ class ArcaneAuthenticationService extends ArcaneService {
return Result.error("No ArcaneAuthInterface has been registered");
}
final Result<bool, String>? result = await authInterface.confirmSignup(
final Result<bool, String>? result = await authInterface!.confirmSignup(
username: email,
confirmationCode: confirmationCode,
);
@@ -251,7 +244,7 @@ class ArcaneAuthenticationService extends ArcaneService {
}
final Future<Result<String, String>>? result =
authInterface.resendVerificationCode(input: email);
authInterface!.resendVerificationCode(input: email);
if (result == null) {
return Result.error(
@@ -277,7 +270,7 @@ class ArcaneAuthenticationService extends ArcaneService {
return Result.error("No ArcaneAuthInterface has been registered");
}
final Result<bool, String>? result = await authInterface.resetPassword(
final Result<bool, String>? result = await authInterface!.resetPassword(
email: email,
newPassword: newPassword,
code: confirmationCode,
+1 -1
View File
@@ -1,6 +1,6 @@
name: arcane_framework
description: "Agnostic Reusable Component Architecture for New Ecosystems: a modern framework for bootstrapping new applications"
version: 1.1.6
version: 1.1.7
repository: https://github.com/hanskokx/arcane_framework
issue_tracker: https://github.com/hanskokx/arcane_framework/issues