diff --git a/packages/wyatt_authentication_bloc/example/lib/presentation/features/app/app.dart b/packages/wyatt_authentication_bloc/example/lib/presentation/features/app/app.dart index 44f9522f..a2afa06e 100644 --- a/packages/wyatt_authentication_bloc/example/lib/presentation/features/app/app.dart +++ b/packages/wyatt_authentication_bloc/example/lib/presentation/features/app/app.dart @@ -23,6 +23,7 @@ import 'package:wyatt_type_utils/wyatt_type_utils.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart'; FutureOrResult onSignUpSuccess( + AuthenticationRepository repo, Account? account, WyattForm form, ) async { @@ -35,9 +36,15 @@ FutureOrResult onSignUpSuccess( return const Ok(id); } -FutureOrResult onAccountChanges(Account? account) async { +FutureOrResult onAccountChanges( + AuthenticationRepository repo, + Account? account, +) async { final id = Random().nextInt(1000); - debugPrint('onAccountChanges: $account, generatedId: $id'); + final token = + await repo.getIdentityToken().fold((value) => value, (error) => 'null'); + + debugPrint('onAccountChanges: $account, token: $token, generatedId: $id'); return Ok(id); } diff --git a/packages/wyatt_authentication_bloc/lib/src/data/repositories/authentication_repository_impl.dart b/packages/wyatt_authentication_bloc/lib/src/data/repositories/authentication_repository_impl.dart index 309b31b3..f5653592 100644 --- a/packages/wyatt_authentication_bloc/lib/src/data/repositories/authentication_repository_impl.dart +++ b/packages/wyatt_authentication_bloc/lib/src/data/repositories/authentication_repository_impl.dart @@ -30,11 +30,15 @@ import 'package:wyatt_form_bloc/wyatt_form_bloc.dart'; import 'package:wyatt_type_utils/wyatt_type_utils.dart'; typedef OnSignUpSuccess = FutureOrResult Function( + AuthenticationRepository repo, Account? account, WyattForm form, ); -typedef OnAuthChange = FutureOrResult Function(Account? account); +typedef OnAuthChange = FutureOrResult Function( + AuthenticationRepository repo, + Account? account, +); class AuthenticationRepositoryImpl extends AuthenticationRepository { @@ -149,6 +153,7 @@ class AuthenticationRepositoryImpl await _authenticationLocalDataSource.storeAccount(account); if (_onSignUpSuccess.isNotNull) { final dataResult = await _onSignUpSuccess!.call( + this, account, _formRepository.accessForm(AuthFormName.signUpForm).clone(), ); @@ -232,7 +237,7 @@ class AuthenticationRepositoryImpl _signUpStream.stream.asBroadcastStream(), _authenticationRemoteDataSource.streamAccount().map((account) async { if (_onAccountChanges.isNotNull && !_pause) { - final dataResult = await _onAccountChanges!.call(account); + final dataResult = await _onAccountChanges!.call(this, account); return dataResult.map((data) { _authenticationLocalDataSource.storeData(data); return AccountWrapperModel(account, data);