- Auth logout no longer throws exceptions, preferring a Result return value instead.

Signed-off-by: Hans Kokx <hans.kokx@hackberry.se>
This commit is contained in:
Hans Kokx
2024-10-25 12:17:10 +02:00
parent a29da7c090
commit 606404b4d3
3 changed files with 15 additions and 12 deletions
+4
View File
@@ -1,3 +1,7 @@
## 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.
## 1.1.2 ## 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.
@@ -155,8 +155,10 @@ class ArcaneAuthenticationService extends ArcaneService {
/// Logs the current user out. Upon successful logout, `status` will be set to /// Logs the current user out. Upon successful logout, `status` will be set to
/// `AuthenticationStatus.unauthenticated`. /// `AuthenticationStatus.unauthenticated`.
Future<void> logOut({Future<void> Function()? onLoggedOut}) async { Future<Result<void, String>> logOut({
if (!isAuthenticated) return; Future<void> Function()? onLoggedOut,
}) async {
if (!isAuthenticated) Result.error("User is not authenticated.");
assert( assert(
_authInterface != null, _authInterface != null,
@@ -165,15 +167,12 @@ class ArcaneAuthenticationService extends ArcaneService {
final Result<void, String> loggedOut = await authInterface.logout(); final Result<void, String> loggedOut = await authInterface.logout();
await loggedOut.fold( if (loggedOut.isSuccess) {
onSuccess: (_) async { setUnauthenticated();
setUnauthenticated(); if (onLoggedOut != null) await onLoggedOut();
if (onLoggedOut != null) await onLoggedOut(); }
},
onError: (e) { return loggedOut;
throw Exception(e);
},
);
} }
/// Logs the user in using an optional, generic `T` type of input. /// Logs the user in using an optional, generic `T` type of input.
+1 -1
View File
@@ -1,6 +1,6 @@
name: arcane_framework name: arcane_framework
description: "Agnostic Reusable Component Architecture for New Ecosystems: a modern framework for bootstrapping new applications" description: "Agnostic Reusable Component Architecture for New Ecosystems: a modern framework for bootstrapping new applications"
version: 1.1.2 version: 1.1.3
repository: https://github.com/hanskokx/arcane_framework repository: https://github.com/hanskokx/arcane_framework
issue_tracker: https://github.com/hanskokx/arcane_framework/issues issue_tracker: https://github.com/hanskokx/arcane_framework/issues