Skip to content

Commit 25a00ee

Browse files
committed
refactor(router): remove unused localization and snackbar redirect
- Remove unused localization import and unused l10n variable - Remove snackbar display for unauthorized access redirect - Add print statement for unauthorized access attempt - Update redirect comment to explain safe redirect logic
1 parent 0446ede commit 25a00ee

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/router/router.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import 'package:flutter_news_app_web_dashboard_full_source_code/content_manageme
2525
import 'package:flutter_news_app_web_dashboard_full_source_code/content_management/view/edit_topic_page.dart';
2626
import 'package:flutter_news_app_web_dashboard_full_source_code/content_management/widgets/filter_dialog/bloc/filter_dialog_bloc.dart';
2727
import 'package:flutter_news_app_web_dashboard_full_source_code/content_management/widgets/filter_dialog/filter_dialog.dart';
28-
import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart';
2928
import 'package:flutter_news_app_web_dashboard_full_source_code/local_ads_management/bloc/filter_local_ads/filter_local_ads_bloc.dart';
3029
import 'package:flutter_news_app_web_dashboard_full_source_code/local_ads_management/view/create_local_banner_ad_page.dart';
3130
import 'package:flutter_news_app_web_dashboard_full_source_code/local_ads_management/view/create_local_interstitial_ad_page.dart';
@@ -66,7 +65,6 @@ GoRouter createRouter({
6665
// --- Redirect Logic ---
6766
redirect: (BuildContext context, GoRouterState state) {
6867
final appStatus = context.read<AppBloc>().state.status;
69-
final l10n = AppLocalizationsX(context).l10n;
7068
final currentLocation = state.matchedLocation;
7169

7270
print(
@@ -116,10 +114,12 @@ GoRouter createRouter({
116114

117115
// Universally allowed routes like 'settings' are exempt from this check.
118116
if (!isAuthorized && destinationRouteName != Routes.settingsName) {
119-
ScaffoldMessenger.of(context).showSnackBar(
120-
SnackBar(content: Text(l10n.unauthorizedAccessRedirect)),
117+
print(
118+
' Action: Unauthorized access to "$destinationRouteName". '
119+
'Redirecting to $overviewPath.',
121120
);
122-
// Redirect unauthorized users to the overview page.
121+
// Redirect unauthorized users to the overview page. This is a safe
122+
// redirect without side effects.
123123
return Routes.overview;
124124
}
125125
// --- End of RBAC ---

0 commit comments

Comments
 (0)