TF-34 Add data layer login for fix bug mock data user
This commit is contained in:
@@ -8,7 +8,7 @@ class AuthenticationRepositoryImpl extends AuthenticationRepository {
|
||||
AuthenticationRepositoryImpl(this.loginDataSource);
|
||||
|
||||
@override
|
||||
Future<User> authenticationUser(Uri baseUrl, UserName userName, Password password) {
|
||||
Future<UserProfile> authenticationUser(Uri baseUrl, UserName userName, Password password) {
|
||||
return loginDataSource.authenticationUser(baseUrl, userName, password);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,10 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:model/model.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/model/response/user_profile_response.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/utils/login_constant.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/user_profile_extension.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart';
|
||||
|
||||
class CredentialRepositoryImpl extends CredentialRepository {
|
||||
@@ -53,4 +57,23 @@ class CredentialRepositoryImpl extends CredentialRepository {
|
||||
Future saveUserName(UserName userName) async {
|
||||
await sharedPreferences.setString(LoginConstant.keyUserName, userName.userName);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<UserProfile> getUserProfile() async {
|
||||
final json = sharedPreferences.getString(LoginConstant.keyUserProfile) ?? '';
|
||||
Map<String, dynamic> mapObject = jsonDecode(json);
|
||||
return UserProfileResponse.fromJson(mapObject).toUserProfile();
|
||||
}
|
||||
|
||||
@override
|
||||
Future removeUserProfile() async {
|
||||
await sharedPreferences.remove(LoginConstant.keyUserProfile);
|
||||
}
|
||||
|
||||
@override
|
||||
Future saveUserProfile(UserProfile userProfile) async {
|
||||
final userProfileResponse = userProfile.toUserProfileResponse();
|
||||
final json = jsonEncode(userProfileResponse.toJson());
|
||||
await sharedPreferences.setString(LoginConstant.keyUserProfile, json);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user