TF-886 Implement GetAuthenticationInfo stored in repository and datasource
This commit is contained in:
@@ -10,12 +10,8 @@ abstract class CredentialRepository {
|
||||
|
||||
Future removeUserName();
|
||||
|
||||
Future<UserName> getUserName();
|
||||
|
||||
Future removePassword();
|
||||
|
||||
Future<Password> getPassword();
|
||||
|
||||
Future saveUserProfile(UserProfile userProfile);
|
||||
|
||||
Future removeUserProfile();
|
||||
@@ -23,4 +19,6 @@ abstract class CredentialRepository {
|
||||
Future<UserProfile> getUserProfile();
|
||||
|
||||
Future<void> storeAuthenticationInfo(AuthenticationInfoCache authenticationInfoCache);
|
||||
|
||||
Future<AuthenticationInfoCache?> getAuthenticationInfoStored();
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import 'dart:core';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/extensions/uri_extension.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart';
|
||||
@@ -15,10 +16,12 @@ class GetCredentialInteractor {
|
||||
Future<Either<Failure, Success>> execute() async {
|
||||
try {
|
||||
final baseUrl = await credentialRepository.getBaseUrl();
|
||||
final userName = await credentialRepository.getUserName();
|
||||
final password = await credentialRepository.getPassword();
|
||||
if (isCredentialValid(baseUrl)) {
|
||||
return Right(GetCredentialViewState(baseUrl, userName, password));
|
||||
final authenticationInfo = await credentialRepository.getAuthenticationInfoStored();
|
||||
if (isCredentialValid(baseUrl) && authenticationInfo != null) {
|
||||
return Right(GetCredentialViewState(
|
||||
baseUrl,
|
||||
UserName(authenticationInfo.username),
|
||||
Password(authenticationInfo.password)));
|
||||
} else {
|
||||
return Left(GetCredentialFailure(BadCredentials()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user