diff --git a/packages/wyatt_authentication_bloc/lib/src/core/core.dart b/packages/wyatt_authentication_bloc/lib/src/core/core.dart index 658cbca0..16b0264b 100644 --- a/packages/wyatt_authentication_bloc/lib/src/core/core.dart +++ b/packages/wyatt_authentication_bloc/lib/src/core/core.dart @@ -1,19 +1,21 @@ // Copyright (C) 2022 WYATT GROUP // Please see the AUTHORS file for details. -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . +export 'constants/form_field.dart'; +export 'constants/form_name.dart'; export 'enums/enums.dart'; export 'exceptions/exceptions.dart'; export 'utils/utils.dart'; diff --git a/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/authentication_cache_data_source_impl.dart b/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/authentication_cache_data_source_impl.dart index 363ee51d..57b1191a 100644 --- a/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/authentication_cache_data_source_impl.dart +++ b/packages/wyatt_authentication_bloc/lib/src/data/data_sources/local/authentication_cache_data_source_impl.dart @@ -15,29 +15,28 @@ // along with this program. If not, see . import 'package:wyatt_architecture/wyatt_architecture.dart'; -import 'package:wyatt_authentication_bloc/src/domain/data_sources/local/authentication_local_data_source.dart'; -import 'package:wyatt_authentication_bloc/src/domain/entities/account.dart'; +import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart'; import 'package:wyatt_type_utils/wyatt_type_utils.dart'; class AuthenticationCacheDataSourceImpl - extends AuthenticationLocalDataSource { + extends AuthenticationCacheDataSource { Account? _account; T? _data; AuthenticationCacheDataSourceImpl(); @override - void storeAccount(Account? account) { + Future storeAccount(Account? account) async { _account = account; } @override - void storeData(T? data) { + Future storeData(T? data) async { _data = data; } @override - Account loadAccount() { + Future loadAccount() async { if (_account.isNotNull) { return _account!; } @@ -45,7 +44,7 @@ class AuthenticationCacheDataSourceImpl } @override - T loadData() { + Future loadData() async { if (_data.isNotNull) { return _data!; } @@ -53,8 +52,16 @@ class AuthenticationCacheDataSourceImpl } @override - void destroy() { + Future destroy() async { _data = null; _account = null; } + + @override + Future> load() async { + if (_account.isNull) { + throw ClientException('Cached account is invalid'); + } + return AccountWrapperModel(_account, _data); + } } diff --git a/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/data_sources.dart b/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/data_sources.dart index 1e726386..11efe02d 100644 --- a/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/data_sources.dart +++ b/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/data_sources.dart @@ -14,6 +14,5 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -export 'local/authentication_biometrics_data_source.dart'; -export 'local/authentication_local_data_source.dart'; +export 'local/authentication_cache_data_source.dart'; export 'remote/authentication_remote_data_source.dart'; diff --git a/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/local/authentication_biometrics_data_source.dart b/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/local/authentication_biometrics_data_source.dart deleted file mode 100644 index 489c9919..00000000 --- a/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/local/authentication_biometrics_data_source.dart +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 WYATT GROUP -// Please see the AUTHORS file for details. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -import 'package:wyatt_architecture/wyatt_architecture.dart'; - -abstract class AuthenticationBiometricsDataSource extends BaseLocalDataSource {} diff --git a/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/local/authentication_local_data_source.dart b/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/local/authentication_cache_data_source.dart similarity index 71% rename from packages/wyatt_authentication_bloc/lib/src/domain/data_sources/local/authentication_local_data_source.dart rename to packages/wyatt_authentication_bloc/lib/src/domain/data_sources/local/authentication_cache_data_source.dart index cd47d32e..c4d357e5 100644 --- a/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/local/authentication_local_data_source.dart +++ b/packages/wyatt_authentication_bloc/lib/src/domain/data_sources/local/authentication_cache_data_source.dart @@ -16,12 +16,14 @@ import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_authentication_bloc/src/domain/entities/account.dart'; +import 'package:wyatt_authentication_bloc/src/domain/entities/account_wrapper.dart'; -abstract class AuthenticationLocalDataSource +abstract class AuthenticationCacheDataSource extends BaseLocalDataSource { - void storeAccount(Account? account); - void storeData(T? data); - Account loadAccount(); - T loadData(); - void destroy(); + Future storeAccount(Account? account); + Future storeData(T? data); + Future loadAccount(); + Future loadData(); + Future> load(); + Future destroy(); }