TF-34 Add domain layer login for fix bug mock data user

This commit is contained in:
dab246
2021-08-25 13:11:24 +07:00
committed by Dat H. Pham
parent b50cec44c2
commit b3e1534de3
5 changed files with 14 additions and 6 deletions
@@ -1,5 +1,5 @@
import 'package:model/model.dart'; import 'package:model/model.dart';
abstract class AuthenticationRepository { abstract class AuthenticationRepository {
Future<User> authenticationUser(Uri baseUrl, UserName userName, Password password); Future<UserProfile> authenticationUser(Uri baseUrl, UserName userName, Password password);
} }
@@ -18,4 +18,10 @@ abstract class CredentialRepository {
Future removePassword(); Future removePassword();
Future<Password> getPassword(); Future<Password> getPassword();
Future saveUserProfile(UserProfile userProfile);
Future removeUserProfile();
Future<UserProfile> getUserProfile();
} }
@@ -2,12 +2,12 @@ import 'package:core/core.dart';
import 'package:model/model.dart'; import 'package:model/model.dart';
class AuthenticationUserViewState extends UIState { class AuthenticationUserViewState extends UIState {
final User user; final UserProfile userProfile;
AuthenticationUserViewState(this.user); AuthenticationUserViewState(this.userProfile);
@override @override
List<Object> get props => [user]; List<Object> get props => [userProfile];
} }
class AuthenticationUserFailure extends FeatureFailure { class AuthenticationUserFailure extends FeatureFailure {
@@ -17,7 +17,8 @@ class AuthenticationInteractor {
await Future.wait([ await Future.wait([
credentialRepository.saveBaseUrl(baseUrl), credentialRepository.saveBaseUrl(baseUrl),
credentialRepository.saveUserName(userName), credentialRepository.saveUserName(userName),
credentialRepository.savePassword(password) credentialRepository.savePassword(password),
credentialRepository.saveUserProfile(user),
]); ]);
return Right(AuthenticationUserViewState(user)); return Right(AuthenticationUserViewState(user));
} catch (e) { } catch (e) {
@@ -15,7 +15,8 @@ class DeleteCredentialInteractor {
await Future.wait([ await Future.wait([
credentialRepository.removeBaseUrl(), credentialRepository.removeBaseUrl(),
credentialRepository.removeUserName(), credentialRepository.removeUserName(),
credentialRepository.removePassword() credentialRepository.removePassword(),
credentialRepository.removeUserProfile(),
]); ]);
return Right(DeleteCredentialSuccess()); return Right(DeleteCredentialSuccess());
} catch (exception) { } catch (exception) {