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

This commit is contained in:
dab246
2021-08-25 13:12:17 +07:00
committed by Dat H. Pham
parent b3e1534de3
commit cae1252fc8
16 changed files with 227 additions and 58 deletions
@@ -1,7 +1,7 @@
import 'package:model/model.dart';
import 'package:tmail_ui_user/features/login/data/datasource/atuthentitcation_datasource.dart';
import 'package:tmail_ui_user/features/login/data/model/request/account_request.dart';
import 'package:tmail_ui_user/features/login/data/model/response/user_response.dart';
import 'package:tmail_ui_user/features/login/data/model/response/user_profile_response.dart';
import 'package:tmail_ui_user/features/login/data/network/login_api.dart';
class AuthenticationDataSourceImpl extends AuthenticationDataSource {
@@ -11,10 +11,10 @@ class AuthenticationDataSourceImpl extends AuthenticationDataSource {
AuthenticationDataSourceImpl(this.loginAPI);
@override
Future<User> authenticationUser(Uri baseUrl, UserName userName, Password password) {
Future<UserProfile> authenticationUser(Uri baseUrl, UserName userName, Password password) {
return Future.sync(() async {
final userResponse = await loginAPI.authenticationUser(baseUrl, AccountRequest(userName, password));
return userResponse.toUser();
final userProfileResponse = await loginAPI.authenticationUser(baseUrl, AccountRequest(userName, password));
return userProfileResponse.toUserProfile();
}).catchError((error) {
throw error;
});