mirror of
https://github.com/hanskokx/arcane_framework.git
synced 2026-05-14 10:29:06 +02:00
Add configuration files and update authentication service error handling
- Introduced .vscode/settings.json and .vscode/launch.json for IDE configuration. - Updated DebugAuthInterface and ArcaneAuthenticationService to return const Result.ok() for consistency. - Added ArcaneTheme class for theme management. - Updated pubspec.yaml to change result_monad dependency version. - Modified authentication_service_test to return const Result.ok() in mock setups. Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -164,10 +164,10 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
Future<void> Function()? onLoggedOut,
|
||||
}) async {
|
||||
if (_authInterface == null) {
|
||||
return Result.error("No ArcaneAuthInterface has been registered");
|
||||
return const Result.error("No ArcaneAuthInterface has been registered");
|
||||
}
|
||||
|
||||
if (!isAuthenticated) Result.error("User is not authenticated.");
|
||||
if (!isAuthenticated) const Result.error("User is not authenticated.");
|
||||
|
||||
final Result<void, String> loggedOut = await authInterface!.logout(
|
||||
onLoggedOut: onLoggedOut,
|
||||
@@ -188,7 +188,7 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
Future<void> Function()? onLoggedIn,
|
||||
}) async {
|
||||
if (_authInterface == null) {
|
||||
return Result.error("No ArcaneAuthInterface has been registered");
|
||||
return const Result.error("No ArcaneAuthInterface has been registered");
|
||||
}
|
||||
|
||||
final Result<void, String> result = await authInterface!.login(
|
||||
@@ -210,11 +210,11 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
T? input,
|
||||
}) async {
|
||||
if (_authInterface == null) {
|
||||
return Result.error("No ArcaneAuthInterface has been registered");
|
||||
return const Result.error("No ArcaneAuthInterface has been registered");
|
||||
}
|
||||
|
||||
if (authInterface is! ArcaneAuthAccountRegistration) {
|
||||
return Result.error(
|
||||
return const Result.error(
|
||||
"The provided ArcaneAuthInterface does not support account registration.",
|
||||
);
|
||||
}
|
||||
@@ -226,7 +226,7 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
);
|
||||
|
||||
if (result == null) {
|
||||
return Result.error(
|
||||
return const Result.error(
|
||||
"Registered ArcaneAuthInterface returned a null value.",
|
||||
);
|
||||
}
|
||||
@@ -241,11 +241,11 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
required String confirmationCode,
|
||||
}) async {
|
||||
if (_authInterface == null) {
|
||||
return Result.error("No ArcaneAuthInterface has been registered");
|
||||
return const Result.error("No ArcaneAuthInterface has been registered");
|
||||
}
|
||||
|
||||
if (authInterface is! ArcaneAuthAccountRegistration) {
|
||||
return Result.error(
|
||||
return const Result.error(
|
||||
"The provided ArcaneAuthInterface does not support account registration.",
|
||||
);
|
||||
}
|
||||
@@ -258,7 +258,7 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
);
|
||||
|
||||
if (result == null) {
|
||||
return Result.error(
|
||||
return const Result.error(
|
||||
"Registered ArcaneAuthInterface returned a null value.",
|
||||
);
|
||||
}
|
||||
@@ -270,11 +270,11 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
/// registration.
|
||||
Future<Result<String, String>> resendVerificationCode(String email) async {
|
||||
if (_authInterface == null) {
|
||||
return Result.error("No ArcaneAuthInterface has been registered");
|
||||
return const Result.error("No ArcaneAuthInterface has been registered");
|
||||
}
|
||||
|
||||
if (authInterface is! ArcaneAuthAccountRegistration) {
|
||||
return Result.error(
|
||||
return const Result.error(
|
||||
"The provided ArcaneAuthInterface does not support account registration.",
|
||||
);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
auth.resendVerificationCode(input: email);
|
||||
|
||||
if (result == null) {
|
||||
return Result.error(
|
||||
return const Result.error(
|
||||
"Registered ArcaneAuthInterface returned a null value.",
|
||||
);
|
||||
}
|
||||
@@ -305,11 +305,11 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
String? confirmationCode,
|
||||
}) async {
|
||||
if (_authInterface == null) {
|
||||
return Result.error("No ArcaneAuthInterface has been registered");
|
||||
return const Result.error("No ArcaneAuthInterface has been registered");
|
||||
}
|
||||
|
||||
if (authInterface is! ArcaneAuthPasswordManagement) {
|
||||
return Result.error(
|
||||
return const Result.error(
|
||||
"The provided ArcaneAuthInterface does not support password management.",
|
||||
);
|
||||
}
|
||||
@@ -323,7 +323,7 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
);
|
||||
|
||||
if (result == null) {
|
||||
return Result.error(
|
||||
return const Result.error(
|
||||
"Registered ArcaneAuthInterface returned a null value.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
class ArcaneTheme extends InheritedWidget {
|
||||
final ThemeMode themeMode;
|
||||
final bool followSystem;
|
||||
final ThemeData? theme;
|
||||
|
||||
const ArcaneTheme({
|
||||
required super.child,
|
||||
this.themeMode = ThemeMode.light,
|
||||
this.followSystem = false,
|
||||
this.theme,
|
||||
super.key,
|
||||
});
|
||||
|
||||
static ArcaneTheme? of(BuildContext context) {
|
||||
return context.dependOnInheritedWidgetOfExactType<ArcaneTheme>();
|
||||
}
|
||||
|
||||
@override
|
||||
bool updateShouldNotify(ArcaneTheme oldWidget) {
|
||||
return themeMode != oldWidget.themeMode ||
|
||||
followSystem != oldWidget.followSystem ||
|
||||
theme != oldWidget.theme;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user