TF-886 Implement GetAuthenticationInfo stored in repository and datasource

This commit is contained in:
dab246
2022-09-06 19:10:50 +07:00
committed by Dat H. Pham
parent b95d294a3c
commit f108f5c726
7 changed files with 21 additions and 40 deletions
@@ -11,4 +11,8 @@ class AuthenticationInfoCacheManager {
AuthenticationInfoCache.keyCacheValue,
authenticationInfoCache);
}
Future<AuthenticationInfoCache?> getAuthenticationInfoStored() {
return _authenticationInfoCacheClient.getItem(AuthenticationInfoCache.keyCacheValue);
}
}
@@ -32,36 +32,16 @@ class CredentialRepositoryImpl extends CredentialRepository {
await sharedPreferences.remove(LoginConstant.keyBaseUrl);
}
@override
Future<Password> getPassword() async {
return Password(sharedPreferences.getString(LoginConstant.keyPassword) ?? '');
}
@override
Future removePassword() async {
await sharedPreferences.remove(LoginConstant.keyPassword);
}
@override
Future savePassword(Password password) async {
await sharedPreferences.setString(LoginConstant.keyPassword, password.value);
}
@override
Future<UserName> getUserName() async {
return UserName(sharedPreferences.getString(LoginConstant.keyUserName) ?? '');
}
@override
Future removeUserName() async {
await sharedPreferences.remove(LoginConstant.keyUserName);
}
@override
Future saveUserName(UserName userName) async {
await sharedPreferences.setString(LoginConstant.keyUserName, userName.userName);
}
@override
Future<UserProfile> getUserProfile() async {
final json = sharedPreferences.getString(LoginConstant.keyUserProfile) ?? '';
@@ -85,4 +65,9 @@ class CredentialRepositoryImpl extends CredentialRepository {
Future<void> storeAuthenticationInfo(AuthenticationInfoCache authenticationInfoCache) {
return _authenticationInfoCacheManager.storeAuthenticationInfo(authenticationInfoCache);
}
@override
Future<AuthenticationInfoCache?> getAuthenticationInfoStored() {
return _authenticationInfoCacheManager.getAuthenticationInfoStored();
}
}