Remove LoginAPI, because it does not belongs to JMAP server
This commit is contained in:
committed by
Dat H. Pham
parent
5fd305d102
commit
afe6095c7e
@@ -1,20 +1,14 @@
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/datasource/authentication_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/login_api.dart';
|
||||
|
||||
class AuthenticationDataSourceImpl extends AuthenticationDataSource {
|
||||
|
||||
final LoginAPI loginAPI;
|
||||
|
||||
AuthenticationDataSourceImpl(this.loginAPI);
|
||||
AuthenticationDataSourceImpl();
|
||||
|
||||
@override
|
||||
Future<UserProfile> authenticationUser(Uri baseUrl, UserName userName, Password password) {
|
||||
return Future.sync(() async {
|
||||
final userProfileResponse = await loginAPI.authenticationUser(baseUrl, AccountRequest(userName, password));
|
||||
return userProfileResponse.toUserProfile();
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
return Future.sync(() {
|
||||
return UserProfile(userName.userName);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class LoginAPI {
|
||||
final DioClient _dioClient;
|
||||
|
||||
LoginAPI(this._dioClient);
|
||||
|
||||
Future<UserProfileResponse> authenticationUser(Uri baseUrl, AccountRequest accountRequest) async {
|
||||
final basicAuth = 'Basic ' + base64Encode(utf8.encode('${accountRequest.userName.userName}:${accountRequest.password.value}'));
|
||||
final resultJson = await _dioClient.post(
|
||||
Endpoint.authentication.generateAuthenticationUrl(baseUrl),
|
||||
options: Options(headers: _buildHeaderRequestParam(basicAuth)),
|
||||
data: accountRequest.toJson());
|
||||
return UserProfileResponse.fromJson(resultJson);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _buildHeaderRequestParam(String authorizationHeader) {
|
||||
final headerParam = _dioClient.getHeaders();
|
||||
headerParam[HttpHeaders.authorizationHeader] = authorizationHeader;
|
||||
return headerParam;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user