forked from baron/baron-sso
테넌트 접근 제한 안내화면 개선
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:userfront/i18n.dart';
|
||||
@@ -5,11 +7,18 @@ import 'package:userfront/core/i18n/locale_utils.dart';
|
||||
import 'package:userfront/core/services/auth_proxy_service.dart';
|
||||
import 'package:userfront/core/services/web_window.dart';
|
||||
import 'package:userfront/core/ui/toast_service.dart';
|
||||
import 'package:userfront/features/auth/domain/consent_error_routing.dart';
|
||||
|
||||
class ConsentScreen extends StatefulWidget {
|
||||
final String consentChallenge;
|
||||
final Future<Map<String, dynamic>> Function(String consentChallenge)?
|
||||
consentInfoLoader;
|
||||
|
||||
const ConsentScreen({super.key, required this.consentChallenge});
|
||||
const ConsentScreen({
|
||||
super.key,
|
||||
required this.consentChallenge,
|
||||
this.consentInfoLoader,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ConsentScreen> createState() => _ConsentScreenState();
|
||||
@@ -93,9 +102,9 @@ class _ConsentScreenState extends State<ConsentScreen> {
|
||||
|
||||
Future<void> _fetchConsentInfo() async {
|
||||
try {
|
||||
final info = await AuthProxyService.getConsentInfo(
|
||||
widget.consentChallenge,
|
||||
);
|
||||
final loader =
|
||||
widget.consentInfoLoader ?? AuthProxyService.getConsentInfo;
|
||||
final info = await loader(widget.consentChallenge);
|
||||
|
||||
// [Skip Logic] 백엔드에서 자동 승인되어 리다이렉트 URL이 온 경우 즉시 이동
|
||||
if (info['redirectTo'] != null) {
|
||||
@@ -139,6 +148,35 @@ class _ConsentScreenState extends State<ConsentScreen> {
|
||||
_consentInfo = info;
|
||||
_isLoading = false;
|
||||
});
|
||||
} on AuthProxyException catch (e) {
|
||||
if (shouldRouteConsentErrorToErrorScreen(e)) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
final localeCode =
|
||||
extractLocaleFromPath(Uri.base) ?? resolvePreferredLocaleCode();
|
||||
final target = buildLocalizedPath(
|
||||
localeCode,
|
||||
Uri(
|
||||
path: '/error',
|
||||
queryParameters: {
|
||||
'error': e.errorCode,
|
||||
'error_description': e.message,
|
||||
if (e.details != null) 'details': jsonEncode(e.details),
|
||||
},
|
||||
),
|
||||
);
|
||||
context.go(target);
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
_error = tr(
|
||||
'msg.userfront.consent.load_error',
|
||||
fallback: 'Failed to load consent information: {{error}}',
|
||||
params: {'error': e.message},
|
||||
);
|
||||
_isLoading = false;
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_error = tr(
|
||||
|
||||
Reference in New Issue
Block a user