@@ -25,9 +25,11 @@ import 'package:tmail_ui_user/features/home/domain/extensions/session_extensions
2525import 'package:tmail_ui_user/features/login/data/network/config/oidc_constant.dart' ;
2626import 'package:tmail_ui_user/features/login/data/network/interceptors/authorization_interceptors.dart' ;
2727import 'package:tmail_ui_user/features/login/domain/exceptions/logout_exception.dart' ;
28+ import 'package:tmail_ui_user/features/login/domain/model/login_source.dart' ;
2829import 'package:tmail_ui_user/features/login/domain/usecases/delete_authority_oidc_interactor.dart' ;
2930import 'package:tmail_ui_user/features/login/domain/usecases/delete_credential_interactor.dart' ;
3031import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart' ;
32+ import 'package:tmail_ui_user/features/login/presentation/model/auto_refresh_arguments.dart' ;
3133import 'package:tmail_ui_user/features/login/presentation/model/login_arguments.dart' ;
3234import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/contact_autocomplete_bindings.dart' ;
3335import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/tmail_autocomplete_bindings.dart' ;
@@ -195,10 +197,12 @@ abstract class BaseController extends GetxController
195197 }
196198 }
197199
198- Future <void > _executeBeforeReconnectAndLogOut () async {
200+ Future <void > _executeBeforeReconnectAndLogOut ({
201+ LoginSource source = LoginSource .manual,
202+ }) async {
199203 twakeAppManager.setExecutingBeforeReconnect (true );
200204 await executeBeforeReconnect ();
201- clearDataAndGoToLoginPage ();
205+ clearDataAndGoToLoginPage (source : source );
202206 }
203207
204208 void onCancelReconnectWhenSessionExpired () {}
@@ -229,9 +233,9 @@ abstract class BaseController extends GetxController
229233 void handleBadCredentialsException () {
230234 log ('$runtimeType ::handleBadCredentialsException:' );
231235 if (twakeAppManager.hasComposer) {
232- _performSaveAndReconnection ();
236+ _performSaveAndReconnection (source : LoginSource .auto );
233237 } else {
234- _performReconnection ();
238+ _performReconnection (source : LoginSource .auto );
235239 }
236240 }
237241
@@ -250,16 +254,20 @@ abstract class BaseController extends GetxController
250254 }
251255 }
252256
253- void _performSaveAndReconnection () {
257+ void _performSaveAndReconnection ({
258+ LoginSource source = LoginSource .manual,
259+ }) {
254260 if (PlatformInfo .isWeb) {
255- _executeBeforeReconnectAndLogOut ();
261+ _executeBeforeReconnectAndLogOut (source : source );
256262 } else if (PlatformInfo .isMobile) {
257- clearDataAndGoToLoginPage ();
263+ clearDataAndGoToLoginPage (source : source );
258264 }
259265 }
260266
261- void _performReconnection () {
262- clearDataAndGoToLoginPage ();
267+ void _performReconnection ({
268+ LoginSource source = LoginSource .manual,
269+ }) {
270+ clearDataAndGoToLoginPage (source: source);
263271 }
264272
265273 void onDataFailureViewState (Failure failure) {
@@ -420,9 +428,24 @@ abstract class BaseController extends GetxController
420428 }
421429 }
422430
423- void removeAllPageAndGoToLogin () {
431+ void removeAllPageAndGoToLogin ({
432+ LoginSource source = LoginSource .manual,
433+ }) {
424434 if (PlatformInfo .isMobile) {
425- pushAndPopAll (AppRoutes .twakeWelcome);
435+ final jmapUrl = dynamicUrlInterceptors.jmapUrl ?? '' ;
436+
437+ final isAutoRefresh = source == LoginSource .auto &&
438+ Get .currentRoute != AppRoutes .login &&
439+ jmapUrl.isNotEmpty;
440+
441+ if (isAutoRefresh) {
442+ pushAndPopAll (
443+ AppRoutes .login,
444+ arguments: AutoRefreshArguments (jmapUrl),
445+ );
446+ } else {
447+ pushAndPopAll (AppRoutes .twakeWelcome);
448+ }
426449 } else {
427450 navigateToLoginPage ();
428451 }
@@ -564,10 +587,12 @@ abstract class BaseController extends GetxController
564587 await beforeReconnectManager? .executeBeforeReconnectListeners ();
565588 }
566589
567- Future <void > clearDataAndGoToLoginPage () async {
568- log ('$runtimeType ::clearDataAndGoToLoginPage:' );
590+ Future <void > clearDataAndGoToLoginPage ({
591+ LoginSource source = LoginSource .manual,
592+ }) async {
593+ log ('$runtimeType ::clearDataAndGoToLoginPage: Login source is $source ' );
569594 await clearAllData ();
570- removeAllPageAndGoToLogin ();
595+ removeAllPageAndGoToLogin (source : source );
571596 }
572597
573598 Future <void > clearAllData () async {
0 commit comments