TF-571 Get token from authentication sso
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
|
||||
import 'package:model/oidc/oidc_configuration.dart';
|
||||
import 'package:model/oidc/request/oidc_request.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
abstract class AuthenticationOIDCRepository {
|
||||
Future<bool> checkOIDCIsAvailable(OIDCRequest oidcRequest);
|
||||
|
||||
Future<OIDCConfiguration> getOIDCConfiguration(Uri baseUri);
|
||||
|
||||
Future<TokenOIDC> getTokenOIDC(String clientId, String redirectUrl, String discoveryUrl, List<String> scopes);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:model/model.dart';
|
||||
|
||||
class GetTokenOIDCSuccess extends UIState {
|
||||
|
||||
final TokenOIDC tokenOIDC;
|
||||
|
||||
GetTokenOIDCSuccess(this.tokenOIDC);
|
||||
|
||||
@override
|
||||
List<Object> get props => [tokenOIDC];
|
||||
}
|
||||
|
||||
class GetTokenOIDCFailure extends FeatureFailure {
|
||||
final dynamic exception;
|
||||
|
||||
GetTokenOIDCFailure(this.exception);
|
||||
|
||||
@override
|
||||
List<Object> get props => [exception];
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
import 'package:core/core.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/get_token_oidc_state.dart';
|
||||
|
||||
class GetTokenOIDCInteractor {
|
||||
|
||||
final AuthenticationOIDCRepository authenticationOIDCRepository;
|
||||
|
||||
GetTokenOIDCInteractor(this.authenticationOIDCRepository);
|
||||
|
||||
Future<Either<Failure, Success>> execute(String clientId, String redirectUrl,
|
||||
String discoveryUrl, List<String> scopes) async {
|
||||
try {
|
||||
final tokenOIDC = await authenticationOIDCRepository.getTokenOIDC(clientId, redirectUrl, discoveryUrl, scopes);
|
||||
return Right<Failure, Success>(GetTokenOIDCSuccess(tokenOIDC));
|
||||
} catch (e) {
|
||||
return Left<Failure, Success>(GetTokenOIDCFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user