From b3e1534de39c141e90bfe9d7d32d3163852b7065 Mon Sep 17 00:00:00 2001 From: dab246 Date: Wed, 25 Aug 2021 13:11:24 +0700 Subject: [PATCH] TF-34 Add domain layer login for fix bug mock data user --- .../login/domain/repository/authentication_repository.dart | 2 +- .../login/domain/repository/credential_repository.dart | 6 ++++++ .../login/domain/state/authentication_user_state.dart | 6 +++--- .../domain/usecases/authentication_user_interactor.dart | 3 ++- .../login/domain/usecases/delete_credential_interactor.dart | 3 ++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/features/login/domain/repository/authentication_repository.dart b/lib/features/login/domain/repository/authentication_repository.dart index 1582de203..01b166ac9 100644 --- a/lib/features/login/domain/repository/authentication_repository.dart +++ b/lib/features/login/domain/repository/authentication_repository.dart @@ -1,5 +1,5 @@ import 'package:model/model.dart'; abstract class AuthenticationRepository { - Future authenticationUser(Uri baseUrl, UserName userName, Password password); + Future authenticationUser(Uri baseUrl, UserName userName, Password password); } \ No newline at end of file diff --git a/lib/features/login/domain/repository/credential_repository.dart b/lib/features/login/domain/repository/credential_repository.dart index 3b07a313e..abfafd672 100644 --- a/lib/features/login/domain/repository/credential_repository.dart +++ b/lib/features/login/domain/repository/credential_repository.dart @@ -18,4 +18,10 @@ abstract class CredentialRepository { Future removePassword(); Future getPassword(); + + Future saveUserProfile(UserProfile userProfile); + + Future removeUserProfile(); + + Future getUserProfile(); } \ No newline at end of file diff --git a/lib/features/login/domain/state/authentication_user_state.dart b/lib/features/login/domain/state/authentication_user_state.dart index cf8d2fc80..c4bc5052f 100644 --- a/lib/features/login/domain/state/authentication_user_state.dart +++ b/lib/features/login/domain/state/authentication_user_state.dart @@ -2,12 +2,12 @@ import 'package:core/core.dart'; import 'package:model/model.dart'; class AuthenticationUserViewState extends UIState { - final User user; + final UserProfile userProfile; - AuthenticationUserViewState(this.user); + AuthenticationUserViewState(this.userProfile); @override - List get props => [user]; + List get props => [userProfile]; } class AuthenticationUserFailure extends FeatureFailure { diff --git a/lib/features/login/domain/usecases/authentication_user_interactor.dart b/lib/features/login/domain/usecases/authentication_user_interactor.dart index 2f3206681..903106eda 100644 --- a/lib/features/login/domain/usecases/authentication_user_interactor.dart +++ b/lib/features/login/domain/usecases/authentication_user_interactor.dart @@ -17,7 +17,8 @@ class AuthenticationInteractor { await Future.wait([ credentialRepository.saveBaseUrl(baseUrl), credentialRepository.saveUserName(userName), - credentialRepository.savePassword(password) + credentialRepository.savePassword(password), + credentialRepository.saveUserProfile(user), ]); return Right(AuthenticationUserViewState(user)); } catch (e) { diff --git a/lib/features/login/domain/usecases/delete_credential_interactor.dart b/lib/features/login/domain/usecases/delete_credential_interactor.dart index 6f796b201..4cce59a8e 100644 --- a/lib/features/login/domain/usecases/delete_credential_interactor.dart +++ b/lib/features/login/domain/usecases/delete_credential_interactor.dart @@ -15,7 +15,8 @@ class DeleteCredentialInteractor { await Future.wait([ credentialRepository.removeBaseUrl(), credentialRepository.removeUserName(), - credentialRepository.removePassword() + credentialRepository.removePassword(), + credentialRepository.removeUserProfile(), ]); return Right(DeleteCredentialSuccess()); } catch (exception) {