TF-606 Implement refresh token when access token expired
This commit is contained in:
@@ -27,4 +27,12 @@ class InvalidBaseUrl extends AuthenticationException {
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class NotFoundAccessTokenException implements Exception {
|
||||
NotFoundAccessTokenException();
|
||||
}
|
||||
|
||||
class AccessTokenInvalidException implements Exception {
|
||||
AccessTokenInvalidException();
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:model/account/account.dart';
|
||||
import 'package:model/account/authentication_type.dart';
|
||||
import 'package:model/oidc/oidc_configuration.dart';
|
||||
import 'package:model/oidc/token_oidc.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/account_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/authentication_oidc_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart';
|
||||
@@ -16,24 +20,19 @@ class GetTokenOIDCInteractor {
|
||||
|
||||
GetTokenOIDCInteractor(this._credentialRepository, this.authenticationOIDCRepository, this._accountRepository);
|
||||
|
||||
Future<Either<Failure, Success>> execute(
|
||||
Uri baseUrl,
|
||||
String clientId,
|
||||
String redirectUrl,
|
||||
String discoveryUrl,
|
||||
List<String> scopes
|
||||
) async {
|
||||
Future<Either<Failure, Success>> execute(Uri baseUrl, OIDCConfiguration config) async {
|
||||
try {
|
||||
log('GetTokenOIDCInteractor::execute(): baseUrl: $baseUrl');
|
||||
final tokenOIDC = await authenticationOIDCRepository
|
||||
.getTokenOIDC(clientId, redirectUrl, discoveryUrl, scopes);
|
||||
.getTokenOIDC(config.clientId, config.redirectUrl, config.discoveryUrl, config.scopes);
|
||||
await Future.wait([
|
||||
_credentialRepository.saveBaseUrl(baseUrl),
|
||||
_accountRepository.setCurrentAccount(Account(
|
||||
tokenOIDC.tokenId.hashCode.toString(),
|
||||
tokenOIDC.tokenIdHash,
|
||||
AuthenticationType.oidc,
|
||||
isSelected: true)),
|
||||
authenticationOIDCRepository.persistTokenOIDC(tokenOIDC)
|
||||
authenticationOIDCRepository.persistTokenOIDC(tokenOIDC),
|
||||
authenticationOIDCRepository.persistAuthorityOidc(config.authority),
|
||||
]);
|
||||
return Right<Failure, Success>(GetTokenOIDCSuccess(tokenOIDC));
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user