TF-2667 Use Username replace UserProfile
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:model/account/password.dart';
|
||||
import 'package:model/user/user_profile.dart';
|
||||
|
||||
abstract class AuthenticationDataSource {
|
||||
Future<UserProfile> authenticationUser(Uri baseUrl, UserName userName, Password password);
|
||||
Future<UserName> authenticationUser(Uri baseUrl, UserName userName, Password password);
|
||||
}
|
||||
@@ -1,16 +1,18 @@
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:model/account/password.dart';
|
||||
import 'package:model/user/user_profile.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/datasource/authentication_datasource.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class AuthenticationDataSourceImpl extends AuthenticationDataSource {
|
||||
|
||||
AuthenticationDataSourceImpl();
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
AuthenticationDataSourceImpl(this._exceptionThrower);
|
||||
|
||||
@override
|
||||
Future<UserProfile> authenticationUser(Uri baseUrl, UserName userName, Password password) {
|
||||
return Future.sync(() {
|
||||
return UserProfile(userName.value);
|
||||
});
|
||||
Future<UserName> authenticationUser(Uri baseUrl, UserName userName, Password password) async {
|
||||
return Future.sync(() async {
|
||||
return userName;
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:model/account/password.dart';
|
||||
import 'package:model/user/user_profile.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/datasource/authentication_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/authentication_repository.dart';
|
||||
|
||||
@@ -10,7 +9,7 @@ class AuthenticationRepositoryImpl extends AuthenticationRepository {
|
||||
AuthenticationRepositoryImpl(this.loginDataSource);
|
||||
|
||||
@override
|
||||
Future<UserProfile> authenticationUser(Uri baseUrl, UserName userName, Password password) {
|
||||
Future<UserName> authenticationUser(Uri baseUrl, UserName userName, Password password) {
|
||||
return loginDataSource.authenticationUser(baseUrl, userName, password);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
import 'package:model/account/password.dart';
|
||||
import 'package:model/user/user_profile.dart';
|
||||
|
||||
abstract class AuthenticationRepository {
|
||||
Future<UserProfile> authenticationUser(Uri baseUrl, UserName userName, Password password);
|
||||
Future<UserName> authenticationUser(Uri baseUrl, UserName userName, Password password);
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:model/user/user_profile.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||
|
||||
class AuthenticationUserLoading extends LoadingState {}
|
||||
|
||||
class AuthenticationUserSuccess extends UIState {
|
||||
final UserProfile userProfile;
|
||||
final UserName userName;
|
||||
|
||||
AuthenticationUserSuccess(this.userProfile);
|
||||
AuthenticationUserSuccess(this.userName);
|
||||
|
||||
@override
|
||||
List<Object> get props => [userProfile];
|
||||
List<Object> get props => [userName];
|
||||
}
|
||||
|
||||
class AuthenticationUserFailure extends FeatureFailure {
|
||||
|
||||
@@ -29,24 +29,24 @@ class AuthenticationInteractor {
|
||||
}) async* {
|
||||
try {
|
||||
yield Right(AuthenticationUserLoading());
|
||||
final user = await authenticationRepository.authenticationUser(baseUrl, userName, password);
|
||||
final username = await authenticationRepository.authenticationUser(baseUrl, userName, password);
|
||||
await Future.wait([
|
||||
credentialRepository.saveBaseUrl(baseUrl),
|
||||
credentialRepository.storeAuthenticationInfo(
|
||||
AuthenticationInfoCache(
|
||||
userName.value,
|
||||
username.value,
|
||||
password.value
|
||||
)
|
||||
),
|
||||
]);
|
||||
await _accountRepository.setCurrentAccount(
|
||||
PersonalAccount(
|
||||
userName.value,
|
||||
username.value,
|
||||
AuthenticationType.basic,
|
||||
isSelected: true
|
||||
)
|
||||
);
|
||||
yield Right(AuthenticationUserSuccess(user));
|
||||
yield Right(AuthenticationUserSuccess(username));
|
||||
} catch (e) {
|
||||
yield Left(AuthenticationUserFailure(e));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user