[HOT-FIX] Webfinger is recalled many times
(cherry picked from commit 1873e0f199c29965543a7504f30308e0024c725c)
This commit is contained in:
@@ -143,16 +143,20 @@ abstract class BaseController extends GetxController
|
|||||||
currentOverlayContext!,
|
currentOverlayContext!,
|
||||||
AppLocalizations.of(currentContext!).badCredentials);
|
AppLocalizations.of(currentContext!).badCredentials);
|
||||||
}
|
}
|
||||||
performInvokeLogoutAction();
|
if (authorizationInterceptors.isAppRunning) {
|
||||||
|
performInvokeLogoutAction();
|
||||||
|
}
|
||||||
return error;
|
return error;
|
||||||
} else if (error is ConnectionError) {
|
} else if (error is ConnectionError) {
|
||||||
logError('BaseController::_performFilterExceptionInError(): ConnectionError');
|
logError('BaseController::_performFilterExceptionInError(): ConnectionError');
|
||||||
if (currentOverlayContext != null && currentContext != null) {
|
if (authorizationInterceptors.isAppRunning) {
|
||||||
_appToast.showToastErrorMessage(
|
if (currentOverlayContext != null && currentContext != null) {
|
||||||
currentOverlayContext!,
|
_appToast.showToastErrorMessage(
|
||||||
AppLocalizations.of(currentContext!).connectionError);
|
currentOverlayContext!,
|
||||||
|
AppLocalizations.of(currentContext!).connectionError);
|
||||||
|
}
|
||||||
|
performInvokeLogoutAction();
|
||||||
}
|
}
|
||||||
performInvokeLogoutAction();
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,17 @@ class AuthorizationInterceptors extends InterceptorsWrapper {
|
|||||||
|
|
||||||
String _getTokenAsBearerHeader(String token) => 'Bearer $token';
|
String _getTokenAsBearerHeader(String token) => 'Bearer $token';
|
||||||
|
|
||||||
|
bool get isAppRunning {
|
||||||
|
switch(_authenticationType) {
|
||||||
|
case AuthenticationType.basic:
|
||||||
|
return _authorization != null;
|
||||||
|
case AuthenticationType.oidc:
|
||||||
|
return _configOIDC != null && _token != null;
|
||||||
|
case AuthenticationType.none:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
_authorization = null;
|
_authorization = null;
|
||||||
_token = null;
|
_token = null;
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import 'package:tmail_ui_user/features/login/domain/usecases/save_login_url_on_m
|
|||||||
import 'package:tmail_ui_user/features/login/domain/usecases/save_login_username_on_mobile_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/save_login_username_on_mobile_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/update_authentication_account_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/update_authentication_account_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/presentation/login_controller.dart';
|
import 'package:tmail_ui_user/features/login/presentation/login_controller.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
|
||||||
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
||||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||||
|
|
||||||
@@ -56,23 +55,20 @@ class LoginBindings extends BaseBindings {
|
|||||||
@override
|
@override
|
||||||
void bindingsController() {
|
void bindingsController() {
|
||||||
Get.lazyPut(() => LoginController(
|
Get.lazyPut(() => LoginController(
|
||||||
Get.find<LogoutOidcInteractor>(),
|
Get.find<AuthenticationInteractor>(),
|
||||||
Get.find<DeleteAuthorityOidcInteractor>(),
|
Get.find<DynamicUrlInterceptors>(),
|
||||||
Get.find<GetAuthenticatedAccountInteractor>(),
|
Get.find<CheckOIDCIsAvailableInteractor>(),
|
||||||
Get.find<UpdateAuthenticationAccountInteractor>(),
|
Get.find<GetOIDCIsAvailableInteractor>(),
|
||||||
Get.find<AuthenticationInteractor>(),
|
Get.find<GetOIDCConfigurationInteractor>(),
|
||||||
Get.find<DynamicUrlInterceptors>(),
|
Get.find<GetTokenOIDCInteractor>(),
|
||||||
Get.find<CheckOIDCIsAvailableInteractor>(),
|
Get.find<AuthenticateOidcOnBrowserInteractor>(),
|
||||||
Get.find<GetOIDCIsAvailableInteractor>(),
|
Get.find<GetAuthenticationInfoInteractor>(),
|
||||||
Get.find<GetOIDCConfigurationInteractor>(),
|
Get.find<GetStoredOidcConfigurationInteractor>(),
|
||||||
Get.find<GetTokenOIDCInteractor>(),
|
Get.find<SaveLoginUrlOnMobileInteractor>(),
|
||||||
Get.find<AuthenticateOidcOnBrowserInteractor>(),
|
Get.find<GetAllRecentLoginUrlOnMobileInteractor>(),
|
||||||
Get.find<GetAuthenticationInfoInteractor>(),
|
Get.find<SaveLoginUsernameOnMobileInteractor>(),
|
||||||
Get.find<GetStoredOidcConfigurationInteractor>(),
|
Get.find<GetAllRecentLoginUsernameOnMobileInteractor>(),
|
||||||
Get.find<SaveLoginUrlOnMobileInteractor>(),
|
Get.find<GetAuthenticatedAccountInteractor>(),
|
||||||
Get.find<GetAllRecentLoginUrlOnMobileInteractor>(),
|
|
||||||
Get.find<SaveLoginUsernameOnMobileInteractor>(),
|
|
||||||
Get.find<GetAllRecentLoginUsernameOnMobileInteractor>(),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,13 @@ import 'package:dartz/dartz.dart';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
|
||||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||||
import 'package:model/account/password.dart';
|
import 'package:model/account/password.dart';
|
||||||
import 'package:model/oidc/oidc_configuration.dart';
|
import 'package:model/oidc/oidc_configuration.dart';
|
||||||
import 'package:model/oidc/request/oidc_request.dart';
|
import 'package:model/oidc/request/oidc_request.dart';
|
||||||
import 'package:model/oidc/response/oidc_response.dart';
|
import 'package:model/oidc/response/oidc_response.dart';
|
||||||
import 'package:model/oidc/token_oidc.dart';
|
import 'package:model/oidc/token_oidc.dart';
|
||||||
import 'package:tmail_ui_user/features/base/reloadable/reloadable_controller.dart';
|
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||||
import 'package:tmail_ui_user/features/login/data/network/oidc_error.dart';
|
import 'package:tmail_ui_user/features/login/data/network/oidc_error.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
|
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/model/login_constants.dart';
|
import 'package:tmail_ui_user/features/login/domain/model/login_constants.dart';
|
||||||
@@ -26,6 +25,7 @@ import 'package:tmail_ui_user/features/login/domain/state/authentication_user_st
|
|||||||
import 'package:tmail_ui_user/features/login/domain/state/check_oidc_is_available_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/check_oidc_is_available_state.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_all_recent_login_url_latest_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_all_recent_login_url_latest_state.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_all_recent_login_username_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_all_recent_login_username_state.dart';
|
||||||
|
import 'package:tmail_ui_user/features/login/domain/state/get_authenticated_account_state.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_authentication_info_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_authentication_info_state.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_oidc_configuration_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_oidc_configuration_state.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/state/get_oidc_is_available_state.dart';
|
import 'package:tmail_ui_user/features/login/domain/state/get_oidc_is_available_state.dart';
|
||||||
@@ -34,7 +34,6 @@ import 'package:tmail_ui_user/features/login/domain/state/get_token_oidc_state.d
|
|||||||
import 'package:tmail_ui_user/features/login/domain/usecases/authenticate_oidc_on_browser_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/authenticate_oidc_on_browser_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/authentication_user_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/authentication_user_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/check_oidc_is_available_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/check_oidc_is_available_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/delete_authority_oidc_interactor.dart';
|
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_all_recent_login_url_on_mobile_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/get_all_recent_login_url_on_mobile_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_all_recent_login_username_on_mobile_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/get_all_recent_login_username_on_mobile_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_authenticated_account_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/get_authenticated_account_interactor.dart';
|
||||||
@@ -45,18 +44,14 @@ import 'package:tmail_ui_user/features/login/domain/usecases/get_stored_oidc_con
|
|||||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_token_oidc_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/get_token_oidc_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/save_login_url_on_mobile_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/save_login_url_on_mobile_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/save_login_username_on_mobile_interactor.dart';
|
import 'package:tmail_ui_user/features/login/domain/usecases/save_login_username_on_mobile_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/login/domain/usecases/update_authentication_account_interactor.dart';
|
|
||||||
import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart';
|
import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart';
|
||||||
import 'package:tmail_ui_user/features/login/presentation/model/login_arguments.dart';
|
import 'package:tmail_ui_user/features/login/presentation/model/login_arguments.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
|
||||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||||
import 'package:tmail_ui_user/main/routes/navigation_router.dart';
|
|
||||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||||
import 'package:tmail_ui_user/main/routes/route_utils.dart';
|
|
||||||
import 'package:tmail_ui_user/main/utils/app_config.dart';
|
import 'package:tmail_ui_user/main/utils/app_config.dart';
|
||||||
import 'package:universal_html/html.dart' as html;
|
import 'package:universal_html/html.dart' as html;
|
||||||
|
|
||||||
class LoginController extends ReloadableController {
|
class LoginController extends BaseController {
|
||||||
|
|
||||||
final AuthenticationInteractor _authenticationInteractor;
|
final AuthenticationInteractor _authenticationInteractor;
|
||||||
final DynamicUrlInterceptors _dynamicUrlInterceptors;
|
final DynamicUrlInterceptors _dynamicUrlInterceptors;
|
||||||
@@ -71,15 +66,12 @@ class LoginController extends ReloadableController {
|
|||||||
final GetAllRecentLoginUrlOnMobileInteractor _getAllRecentLoginUrlOnMobileInteractor;
|
final GetAllRecentLoginUrlOnMobileInteractor _getAllRecentLoginUrlOnMobileInteractor;
|
||||||
final SaveLoginUsernameOnMobileInteractor _saveLoginUsernameOnMobileInteractor;
|
final SaveLoginUsernameOnMobileInteractor _saveLoginUsernameOnMobileInteractor;
|
||||||
final GetAllRecentLoginUsernameOnMobileInteractor _getAllRecentLoginUsernameOnMobileInteractor;
|
final GetAllRecentLoginUsernameOnMobileInteractor _getAllRecentLoginUsernameOnMobileInteractor;
|
||||||
|
final GetAuthenticatedAccountInteractor _getAuthenticatedAccountInteractor;
|
||||||
|
|
||||||
final TextEditingController urlInputController = TextEditingController();
|
final TextEditingController urlInputController = TextEditingController();
|
||||||
final TextEditingController usernameInputController = TextEditingController();
|
final TextEditingController usernameInputController = TextEditingController();
|
||||||
|
|
||||||
LoginController(
|
LoginController(
|
||||||
LogoutOidcInteractor logoutOidcInteractor,
|
|
||||||
DeleteAuthorityOidcInteractor deleteAuthorityOidcInteractor,
|
|
||||||
GetAuthenticatedAccountInteractor getAuthenticatedAccountInteractor,
|
|
||||||
UpdateAuthenticationAccountInteractor updateAuthenticationAccountInteractor,
|
|
||||||
this._authenticationInteractor,
|
this._authenticationInteractor,
|
||||||
this._dynamicUrlInterceptors,
|
this._dynamicUrlInterceptors,
|
||||||
this._checkOIDCIsAvailableInteractor,
|
this._checkOIDCIsAvailableInteractor,
|
||||||
@@ -93,9 +85,7 @@ class LoginController extends ReloadableController {
|
|||||||
this._getAllRecentLoginUrlOnMobileInteractor,
|
this._getAllRecentLoginUrlOnMobileInteractor,
|
||||||
this._saveLoginUsernameOnMobileInteractor,
|
this._saveLoginUsernameOnMobileInteractor,
|
||||||
this._getAllRecentLoginUsernameOnMobileInteractor,
|
this._getAllRecentLoginUsernameOnMobileInteractor,
|
||||||
) : super(
|
this._getAuthenticatedAccountInteractor,
|
||||||
getAuthenticatedAccountInteractor,
|
|
||||||
updateAuthenticationAccountInteractor
|
|
||||||
);
|
);
|
||||||
|
|
||||||
final loginFormType = LoginFormType.baseUrlForm.obs;
|
final loginFormType = LoginFormType.baseUrlForm.obs;
|
||||||
@@ -141,10 +131,12 @@ class LoginController extends ReloadableController {
|
|||||||
void handleFailureViewState(Failure failure) {
|
void handleFailureViewState(Failure failure) {
|
||||||
super.handleFailureViewState(failure);
|
super.handleFailureViewState(failure);
|
||||||
if (failure is GetAuthenticationInfoFailure) {
|
if (failure is GetAuthenticationInfoFailure) {
|
||||||
getAuthenticatedAccountAction();
|
_getAuthenticatedAccountAction();
|
||||||
} else if (failure is CheckOIDCIsAvailableFailure ||
|
} else if (failure is CheckOIDCIsAvailableFailure ||
|
||||||
failure is GetStoredOidcConfigurationFailure ||
|
failure is GetStoredOidcConfigurationFailure ||
|
||||||
failure is GetOIDCIsAvailableFailure) {
|
failure is GetOIDCIsAvailableFailure ||
|
||||||
|
failure is GetAuthenticatedAccountFailure ||
|
||||||
|
failure is NoAuthenticatedAccountFailure) {
|
||||||
_showFormLoginWithCredentialAction();
|
_showFormLoginWithCredentialAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,14 +165,11 @@ class LoginController extends ReloadableController {
|
|||||||
@override
|
@override
|
||||||
void handleExceptionAction({Failure? failure, Exception? exception}) {
|
void handleExceptionAction({Failure? failure, Exception? exception}) {
|
||||||
super.handleExceptionAction(failure: failure, exception: exception);
|
super.handleExceptionAction(failure: failure, exception: exception);
|
||||||
clearState();
|
if (failure is CheckOIDCIsAvailableFailure || failure is GetOIDCIsAvailableFailure) {
|
||||||
}
|
_showFormLoginWithCredentialAction();
|
||||||
|
} else {
|
||||||
@override
|
clearState();
|
||||||
void handleReloaded(Session session) {
|
}
|
||||||
pushAndPop(
|
|
||||||
RouteUtils.generateNavigationRoute(AppRoutes.dashboard, NavigationRouter()),
|
|
||||||
arguments: session);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _getAuthenticationInfo() {
|
void _getAuthenticationInfo() {
|
||||||
@@ -191,6 +180,10 @@ class LoginController extends ReloadableController {
|
|||||||
consumeState(_getStoredOidcConfigurationInteractor.execute());
|
consumeState(_getStoredOidcConfigurationInteractor.execute());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _getAuthenticatedAccountAction() {
|
||||||
|
consumeState(_getAuthenticatedAccountInteractor.execute());
|
||||||
|
}
|
||||||
|
|
||||||
void handleNextInUrlInputFormPress() {
|
void handleNextInUrlInputFormPress() {
|
||||||
_saveRecentLoginUrl();
|
_saveRecentLoginUrl();
|
||||||
_checkOIDCIsAvailable();
|
_checkOIDCIsAvailable();
|
||||||
|
|||||||
@@ -23,31 +23,33 @@ class RemoteExceptionThrower extends ExceptionThrower {
|
|||||||
} else {
|
} else {
|
||||||
if (error is DioError) {
|
if (error is DioError) {
|
||||||
logError('RemoteExceptionThrower::throwException():type: ${error.type} | response: ${error.response} | error: ${error.error}');
|
logError('RemoteExceptionThrower::throwException():type: ${error.type} | response: ${error.response} | error: ${error.error}');
|
||||||
switch (error.type) {
|
if (error.response != null) {
|
||||||
case DioErrorType.connectionTimeout:
|
if (error.response!.statusCode == HttpStatus.internalServerError) {
|
||||||
throw ConnectionTimeout(message: error.message);
|
throw const InternalServerError();
|
||||||
case DioErrorType.connectionError:
|
} else if (error.response!.statusCode == HttpStatus.badGateway) {
|
||||||
throw ConnectionError(message: error.message);
|
throw BadGateway();
|
||||||
default:
|
} else if (error.response!.statusCode == HttpStatus.unauthorized) {
|
||||||
if (error.response?.statusCode == HttpStatus.internalServerError) {
|
throw const BadCredentialsException();
|
||||||
throw const InternalServerError();
|
} else {
|
||||||
} else if (error.response?.statusCode == HttpStatus.badGateway) {
|
throw UnknownError(
|
||||||
throw BadGateway();
|
code: error.response!.statusCode,
|
||||||
} else if (error.response?.statusCode == HttpStatus.unauthorized) {
|
message: error.response!.statusMessage);
|
||||||
throw const BadCredentialsException();
|
}
|
||||||
} else if (error.error is SocketException) {
|
} else {
|
||||||
throw const SocketError();
|
switch (error.type) {
|
||||||
} else {
|
case DioErrorType.connectionTimeout:
|
||||||
if (error.response != null) {
|
throw ConnectionTimeout(message: error.message);
|
||||||
throw UnknownError(
|
case DioErrorType.connectionError:
|
||||||
code: error.response!.statusCode,
|
throw ConnectionError(message: error.message);
|
||||||
message: error.response!.statusMessage);
|
default:
|
||||||
|
if (error.error is SocketException) {
|
||||||
|
throw const SocketError();
|
||||||
} else if (error.error != null) {
|
} else if (error.error != null) {
|
||||||
throw UnknownError(message: error.error!.toString());
|
throw UnknownError(message: error.error!.toString());
|
||||||
} else {
|
} else {
|
||||||
throw const UnknownError();
|
throw const UnknownError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (error is ErrorMethodResponseException) {
|
} else if (error is ErrorMethodResponseException) {
|
||||||
final errorResponse = error.errorResponse as ErrorMethodResponse;
|
final errorResponse = error.errorResponse as ErrorMethodResponse;
|
||||||
|
|||||||
Reference in New Issue
Block a user