Handle web finger to get token in HomeController
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -42,8 +42,6 @@ class CanNotFoundUserName implements Exception {}
|
||||
|
||||
class CanNotFoundPassword implements Exception {}
|
||||
|
||||
class CanNotAuthenticationInfoOnWeb implements Exception {}
|
||||
|
||||
class NotFoundAuthenticationInfoCache implements Exception {}
|
||||
|
||||
class CanNotFoundSaasServerUrl implements Exception {}
|
||||
|
||||
@@ -38,4 +38,6 @@ abstract class AuthenticationOIDCRepository {
|
||||
List<String> scopes);
|
||||
|
||||
Future<String> getAuthenticationInfo();
|
||||
|
||||
Future<void> removeAuthDestinationUrl();
|
||||
}
|
||||
@@ -9,11 +9,16 @@ class GetTokenOIDCSuccess extends UIState {
|
||||
|
||||
final TokenOIDC tokenOIDC;
|
||||
final OIDCConfiguration configuration;
|
||||
final Uri baseUri;
|
||||
|
||||
GetTokenOIDCSuccess(this.tokenOIDC, this.configuration);
|
||||
GetTokenOIDCSuccess(
|
||||
this.tokenOIDC,
|
||||
this.configuration,
|
||||
this.baseUri,
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object> get props => [tokenOIDC, configuration];
|
||||
List<Object> get props => [tokenOIDC, configuration, baseUri];
|
||||
}
|
||||
|
||||
class GetTokenOIDCFailure extends FeatureFailure {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
|
||||
class RemovingAuthDestinationUrl extends LoadingState {}
|
||||
|
||||
class RemoveAuthDestinationUrlSuccess extends UIState {}
|
||||
|
||||
class RemoveAuthDestinationUrlFailure extends FeatureFailure {
|
||||
RemoveAuthDestinationUrlFailure(dynamic exception)
|
||||
: super(exception: exception);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class AuthenticateOidcOnBrowserInteractor {
|
||||
|
||||
AuthenticateOidcOnBrowserInteractor(this.authenticationOIDCRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(Uri baseUrl, OIDCConfiguration config) async* {
|
||||
Stream<Either<Failure, Success>> execute(OIDCConfiguration config) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(AuthenticateOidcOnBrowserLoading());
|
||||
await authenticationOIDCRepository.authenticateOidcOnBrowser(
|
||||
|
||||
@@ -23,7 +23,7 @@ class GetTokenOIDCInteractor {
|
||||
|
||||
GetTokenOIDCInteractor(this._credentialRepository, this.authenticationOIDCRepository, this._accountRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(Uri baseUrl, OIDCConfiguration config) async* {
|
||||
Stream<Either<Failure, Success>> execute(Uri baseUri, OIDCConfiguration config) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(GetTokenOIDCLoading());
|
||||
final tokenOIDC = await authenticationOIDCRepository.getTokenOIDC(
|
||||
@@ -33,7 +33,7 @@ class GetTokenOIDCInteractor {
|
||||
config.scopes);
|
||||
|
||||
await Future.wait([
|
||||
_credentialRepository.saveBaseUrl(baseUrl),
|
||||
_credentialRepository.saveBaseUrl(baseUri),
|
||||
authenticationOIDCRepository.persistTokenOIDC(tokenOIDC),
|
||||
authenticationOIDCRepository.persistOidcConfiguration(config),
|
||||
]);
|
||||
@@ -45,7 +45,11 @@ class GetTokenOIDCInteractor {
|
||||
isSelected: true
|
||||
)
|
||||
);
|
||||
yield Right<Failure, Success>(GetTokenOIDCSuccess(tokenOIDC, config));
|
||||
yield Right<Failure, Success>(GetTokenOIDCSuccess(
|
||||
tokenOIDC,
|
||||
config,
|
||||
baseUri,
|
||||
));
|
||||
} on PlatformException catch (e) {
|
||||
logError('GetTokenOIDCInteractor::execute(): PlatformException ${e.message} - ${e.stacktrace}');
|
||||
if (NoSuitableBrowserForOIDCException.verifyException(e)) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/authentication_oidc_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/remove_auth_destination_url_state.dart';
|
||||
|
||||
class RemoveAuthDestinationUrlInteractor {
|
||||
final AuthenticationOIDCRepository _authenticationOIDCRepository;
|
||||
|
||||
const RemoveAuthDestinationUrlInteractor(this._authenticationOIDCRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute() async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(RemovingAuthDestinationUrl());
|
||||
await _authenticationOIDCRepository.removeAuthDestinationUrl();
|
||||
yield Right<Failure, Success>(RemoveAuthDestinationUrlSuccess());
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(RemoveAuthDestinationUrlFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user