6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 79e75e8b

AuthorMikkel Thygesen<mth@dwarf.dk>
Date2025-02-05 14:58:42 +0100
455: Fixed key not getting provisioned

Changed files

comwell_key_app/lib/authentication/authentication_repository.dart | 6 +-----
 comwell_key_app/lib/authentication/bloc/authentication_bloc.dart  | 1 +
 comwell_key_app/lib/comwell_app.dart                              | 2 +-
 comwell_key_app/lib/services/http_client.dart                     | 1 +
 comwell_key_app/lib/utils/seos_repository.dart                    | 8 --------
 5 files changed, 4 insertions(+), 14 deletions(-)

Diff

diff --git a/comwell_key_app/lib/authentication/authentication_repository.dart b/comwell_key_app/lib/authentication/authentication_repository.dart
index ea5a7d30..d0cfa02c 100644
--- a/comwell_key_app/lib/authentication/authentication_repository.dart
+++ b/comwell_key_app/lib/authentication/authentication_repository.dart
@@ -11,16 +11,12 @@ import '../utils/locator.dart';
import '../utils/seos_repository.dart';
class AuthenticationRepository {
- late SecureStorage secureStorage;
+ final SecureStorage secureStorage = SecureStorage();
final _controller = StreamController<AuthenticationStatus>.broadcast();
final seos = locator<SeosRepository>();
final database = locator<ComwellDatabase>();
final api = Api();
- AuthenticationRepository() {
- secureStorage = SecureStorage();
- }
-
Stream<AuthenticationStatus> get status async* {
yield* _controller.stream.map((status) {
_onAuthResult(status);
diff --git a/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart b/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart
index 129777ec..aa04deec 100644
--- a/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart
+++ b/comwell_key_app/lib/authentication/bloc/authentication_bloc.dart
@@ -19,6 +19,7 @@ class AuthenticationBloc
on<AuthenticationLogoutPressed>(_onLogoutPressed);
on<AuthenticationLoginPressed>(_onLoginPressed);
on<AuthenticationRequestFailed>(_loginErrorFromAzureB2C);
+ add(AuthenticationSubscriptionRequested());
}
void _onLogoutPressed(
diff --git a/comwell_key_app/lib/comwell_app.dart b/comwell_key_app/lib/comwell_app.dart
index 378c1b81..01398afc 100644
--- a/comwell_key_app/lib/comwell_app.dart
+++ b/comwell_key_app/lib/comwell_app.dart
@@ -28,7 +28,7 @@ class ComwellApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocProvider<AuthenticationBloc>(
- create: (context) => authBloc..add(AuthenticationSubscriptionRequested()),
+ create: (context) => authBloc,
child: MultiBlocProvider(
providers: blocProviderList,
child: MaterialApp.router(
diff --git a/comwell_key_app/lib/services/http_client.dart b/comwell_key_app/lib/services/http_client.dart
index 307c87ca..8e9cd4f6 100644
--- a/comwell_key_app/lib/services/http_client.dart
+++ b/comwell_key_app/lib/services/http_client.dart
@@ -1,5 +1,6 @@
import 'package:comwell_key_app/services/interceptors/response_handle_interceptor.dart';
import 'package:dio/dio.dart';
+import 'package:flutter/foundation.dart';
class HttpClient {
diff --git a/comwell_key_app/lib/utils/seos_repository.dart b/comwell_key_app/lib/utils/seos_repository.dart
index 87b5a978..cf4bbe8b 100644
--- a/comwell_key_app/lib/utils/seos_repository.dart
+++ b/comwell_key_app/lib/utils/seos_repository.dart
@@ -55,15 +55,7 @@ class SeosRepository {
Future<void> provisionKey({required String bookingId}) async {
try {
- final hasKey = await secureStorage.read(constants.hasKey);
- if (hasKey != null) {
- final DateTime hasKeyDate = DateTime.parse(hasKey);
- if (DateTime.now().difference(hasKeyDate).inDays < 1) {
- return;
- }
- }
await api.provisionKey(bookingId);
- secureStorage.write(constants.hasKey, DateTime.now().toString());
await seosMobileKeysPlugin.updateEndpoint();
} catch (e) {
throw Exception('Failed to provision a key - ${e.toString()}');