1
0
forked from baron/baron-sso

#269 진행. 리다이렉트 등 파라미터 전체 전달

This commit is contained in:
Lectom C Han
2026-02-19 10:05:07 +09:00
parent 37e8fc4991
commit 7808d81bb4
7 changed files with 349 additions and 38 deletions

View File

@@ -21,6 +21,7 @@ import 'core/services/auth_token_store.dart';
import 'core/services/logger_service.dart';
import 'core/notifiers/auth_notifier.dart';
import 'core/i18n/locale_gate.dart';
import 'core/i18n/locale_registry.dart';
import 'core/i18n/locale_utils.dart';
import 'core/i18n/toml_asset_loader.dart';
import 'package:logging/logging.dart';
@@ -45,6 +46,7 @@ void main() async {
WidgetsFlutterBinding.ensureInitialized();
usePathUrlStrategy();
await EasyLocalization.ensureInitialized();
await LocaleRegistry.initialize();
// 1. Global Error Handling
FlutterError.onError = (details) {
@@ -78,11 +80,16 @@ void main() async {
runApp(
// URL(/en, /ko)이 있으면 우선 적용해서 첫 렌더부터 올바른 언어로 시작합니다.
() {
final supportedLocaleCodes = LocaleRegistry.supportedLocaleCodes;
final supportedLocales = supportedLocaleCodes
.map((code) => Locale(code))
.toList(growable: false);
final fallbackLocaleCode = LocaleRegistry.fallbackLocaleCode;
final initialLocaleCode =
extractLocaleFromPath(Uri.base) ?? resolvePreferredLocaleCode();
return EasyLocalization(
supportedLocales: const [Locale('en'), Locale('ko')],
fallbackLocale: const Locale('en'),
supportedLocales: supportedLocales,
fallbackLocale: Locale(fallbackLocaleCode),
startLocale: Locale(initialLocaleCode),
saveLocale: false,
path: 'assets/translations',
@@ -143,8 +150,13 @@ final _router = GoRouter(
final redirectUrl =
state.uri.queryParameters['redirect_uri'] ??
state.uri.queryParameters['redirect_url'];
_routerLogger.info("Navigating to /login, redirect: $redirectUrl");
return LoginScreen(key: state.pageKey, redirectUrl: redirectUrl);
_routerLogger.info(
"Navigating to /login, redirect: $redirectUrl",
);
return LoginScreen(
key: state.pageKey,
redirectUrl: redirectUrl,
);
},
),
GoRoute(
@@ -153,7 +165,9 @@ final _router = GoRouter(
final consentChallenge =
state.uri.queryParameters['consent_challenge'];
if (consentChallenge == null) {
_routerLogger.warning("Consent screen loaded without a challenge.");
_routerLogger.warning(
"Consent screen loaded without a challenge.",
);
return const Scaffold(
body: Center(
child: Text('Error: Consent challenge is missing.'),
@@ -241,8 +255,7 @@ final _router = GoRouter(
return ErrorScreen(
errorId: params['id'],
errorCode: params['error'],
description:
params['error_description'] ?? params['message'],
description: params['error_description'] ?? params['message'],
);
},
),
@@ -252,9 +265,7 @@ final _router = GoRouter(
_routerLogger.info("Navigating to /settings (disabled)");
return ErrorScreen(
errorCode: 'settings_disabled',
description: tr(
'msg.userfront.settings.disabled',
),
description: tr('msg.userfront.settings.disabled'),
);
},
),
@@ -333,13 +344,7 @@ final _router = GoRouter(
// If not logged in and trying to access a protected page, redirect to /signin
if (!isLoggedIn) {
_routerLogger.info("Not logged in, redirecting to /signin");
// Preserve OIDC challenge if present
final loginChallenge = state.uri.queryParameters['login_challenge'];
final locale = requestedLocale;
if (loginChallenge != null) {
return '/$locale/signin?login_challenge=$loginChallenge';
}
return '/$locale/signin';
return buildSigninRedirectPath(requestedLocale, state.uri);
}
// If logged in and trying to access login page, redirect to root (dashboard)