TF-940 Update apiUrl to baseUrl in interceptor after when get session success

This commit is contained in:
dab246
2022-09-21 18:08:13 +07:00
committed by Dat H. Pham
parent adffd1368b
commit 6bbc63cc2e
2 changed files with 15 additions and 3 deletions
@@ -1,3 +1,4 @@
import 'package:core/data/network/config/dynamic_url_interceptors.dart';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/utils/app_toast.dart'; import 'package:core/presentation/utils/app_toast.dart';
import 'package:core/domain/exceptions/remote_exception.dart'; import 'package:core/domain/exceptions/remote_exception.dart';
@@ -20,6 +21,7 @@ class SessionController extends GetxController {
final DeleteAuthorityOidcInteractor _deleteAuthorityOidcInteractor; final DeleteAuthorityOidcInteractor _deleteAuthorityOidcInteractor;
final AuthorizationInterceptors _authorizationInterceptors; final AuthorizationInterceptors _authorizationInterceptors;
final AppToast _appToast; final AppToast _appToast;
final DynamicUrlInterceptors _dynamicUrlInterceptors;
SessionController( SessionController(
this._getSessionInteractor, this._getSessionInteractor,
@@ -27,7 +29,9 @@ class SessionController extends GetxController {
this._cachingManager, this._cachingManager,
this._deleteAuthorityOidcInteractor, this._deleteAuthorityOidcInteractor,
this._authorizationInterceptors, this._authorizationInterceptors,
this._appToast); this._appToast,
this._dynamicUrlInterceptors,
);
@override @override
void onReady() { void onReady() {
@@ -76,7 +80,13 @@ class SessionController extends GetxController {
pushAndPopAll(AppRoutes.LOGIN); pushAndPopAll(AppRoutes.LOGIN);
} }
void _goToMailboxDashBoard(GetSessionSuccess getSessionSuccess) { void _goToMailboxDashBoard(GetSessionSuccess success) {
pushAndPop(AppRoutes.MAILBOX_DASHBOARD, arguments: getSessionSuccess.session); final apiUrl = success.session.apiUrl.toString();
if (apiUrl.isNotEmpty) {
_dynamicUrlInterceptors.changeBaseUrl(apiUrl);
pushAndPop(AppRoutes.MAILBOX_DASHBOARD, arguments: success.session);
} else {
_goToLogin();
}
} }
} }
@@ -1,3 +1,4 @@
import 'package:core/data/network/config/dynamic_url_interceptors.dart';
import 'package:core/presentation/utils/app_toast.dart'; import 'package:core/presentation/utils/app_toast.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:tmail_ui_user/features/base/base_bindings.dart'; import 'package:tmail_ui_user/features/base/base_bindings.dart';
@@ -28,6 +29,7 @@ class SessionPageBindings extends BaseBindings {
Get.find<DeleteAuthorityOidcInteractor>(), Get.find<DeleteAuthorityOidcInteractor>(),
Get.find<AuthorizationInterceptors>(), Get.find<AuthorizationInterceptors>(),
Get.find<AppToast>(), Get.find<AppToast>(),
Get.find<DynamicUrlInterceptors>(),
)); ));
} }