diff --git a/locales/en.toml b/locales/en.toml index 1acc7307..c00eeff4 100644 --- a/locales/en.toml +++ b/locales/en.toml @@ -578,6 +578,27 @@ success = "Success" [msg.userfront.login_success] subtitle = "Subtitle" +[msg.userfront.consent] +accept_error = "Failed to process consent: {{error}}" +client_id = "Client ID: {{id}}" +client_unknown = "Unknown application" +description = "The service below is requesting access to your account information.\nPlease choose whether to continue." +load_error = "Failed to load consent information: {{error}}" +missing_redirect = "Consent was processed, but the redirect URL was missing." +redirect_notice = "After consent, you will be redirected automatically." +scope_count = "Total {{count}}" + +[msg.userfront.consent.cancel] +confirm = "If you cancel consent, you will not be able to use this service. Do you want to cancel?" +error = "An error occurred while cancelling consent: {{error}}" + +[msg.userfront.consent.scope] +email = "Email address (account identification and notifications)" +offline_access = "Offline access (keep signed in)" +openid = "OpenID authentication information (signin session check)" +phone = "Phone number (identity verification and notifications)" +profile = "Basic profile information (name, user identifier)" + [msg.userfront.profile] department_missing = "Department Missing" department_required = "Department Required" @@ -1609,6 +1630,15 @@ later = "Later" qr = "QR" title = "Title" +[ui.userfront.consent] +accept = "Agree and continue" +requested_scopes = "Requested permissions" +title = "Permission request" + +[ui.userfront.consent.cancel] +confirm_button = "Yes, cancel" +title = "Cancel consent" + [ui.userfront.nav] dashboard = "Dashboard" logout = "Logout" diff --git a/locales/ko.toml b/locales/ko.toml index 56552cb1..b86a9f67 100644 --- a/locales/ko.toml +++ b/locales/ko.toml @@ -578,6 +578,27 @@ success = "로그인 승인에 성공했습니다." [msg.userfront.login_success] subtitle = "성공적으로 로그인되었습니다." +[msg.userfront.consent] +accept_error = "동의 처리에 실패했습니다: {{error}}" +client_id = "클라이언트 ID: {{id}}" +client_unknown = "알 수 없는 앱" +description = "아래 서비스가 회원님의 계정 정보에 접근하려고 합니다.\n계속 진행하려면 동의 여부를 선택해 주세요." +load_error = "동의 정보를 불러오는데 실패했습니다: {{error}}" +missing_redirect = "동의가 처리되었으나 리다이렉트 URL을 받지 못했습니다." +redirect_notice = "동의 후 자동으로 서비스로 이동합니다." +scope_count = "총 {{count}}개" + +[msg.userfront.consent.cancel] +confirm = "권한 동의를 취소하면 해당 서비스를 이용할 수 없습니다. 취소하시겠습니까?" +error = "취소 처리 중 오류가 발생했습니다: {{error}}" + +[msg.userfront.consent.scope] +email = "이메일 주소 (계정 식별 및 알림 용도)" +offline_access = "오프라인 접근 (로그인 유지)" +openid = "OpenID 인증 정보 (로그인 상태 확인)" +phone = "휴대폰 번호 (본인 인증 및 알림)" +profile = "기본 프로필 정보 (이름, 사용자 식별자)" + [msg.userfront.profile] department_missing = "소속 정보 없음" department_required = "소속을 입력해주세요." @@ -1608,6 +1629,15 @@ later = "나중에 하기 (대시보드로 이동)" qr = "QR 인증 (카메라 켜기)" title = "로그인 완료" +[ui.userfront.consent] +accept = "동의하고 계속하기" +requested_scopes = "요청된 권한" +title = "접근 권한 요청" + +[ui.userfront.consent.cancel] +confirm_button = "예, 취소합니다" +title = "동의 취소" + [ui.userfront.nav] dashboard = "대시보드" logout = "로그아웃" diff --git a/locales/template.toml b/locales/template.toml index 10013546..452d49be 100644 --- a/locales/template.toml +++ b/locales/template.toml @@ -578,6 +578,27 @@ success = "" [msg.userfront.login_success] subtitle = "" +[msg.userfront.consent] +accept_error = "" +client_id = "" +client_unknown = "" +description = "" +load_error = "" +missing_redirect = "" +redirect_notice = "" +scope_count = "" + +[msg.userfront.consent.cancel] +confirm = "" +error = "" + +[msg.userfront.consent.scope] +email = "" +offline_access = "" +openid = "" +phone = "" +profile = "" + [msg.userfront.profile] department_missing = "" department_required = "" @@ -1608,6 +1629,15 @@ later = "" qr = "" title = "" +[ui.userfront.consent] +accept = "" +requested_scopes = "" +title = "" + +[ui.userfront.consent.cancel] +confirm_button = "" +title = "" + [ui.userfront.nav] dashboard = "" logout = "" diff --git a/userfront/assets/translations/en.toml b/userfront/assets/translations/en.toml index 06157018..24e137c2 100644 --- a/userfront/assets/translations/en.toml +++ b/userfront/assets/translations/en.toml @@ -179,6 +179,27 @@ success = "Success" [msg.userfront.login_success] subtitle = "Subtitle" +[msg.userfront.consent] +accept_error = "Failed to process consent: {error}" +client_id = "Client ID: {id}" +client_unknown = "Unknown application" +description = "The service below is requesting access to your account information.\nPlease choose whether to continue." +load_error = "Failed to load consent information: {error}" +missing_redirect = "Consent was processed, but the redirect URL was missing." +redirect_notice = "After consent, you will be redirected automatically." +scope_count = "Total {count}" + +[msg.userfront.consent.cancel] +confirm = "If you cancel consent, you will not be able to use this service. Do you want to cancel?" +error = "An error occurred while cancelling consent: {error}" + +[msg.userfront.consent.scope] +email = "Email address (account identification and notifications)" +offline_access = "Offline access (keep signed in)" +openid = "OpenID authentication information (signin session check)" +phone = "Phone number (identity verification and notifications)" +profile = "Basic profile information (name, user identifier)" + [msg.userfront.profile] department_missing = "Department Missing" department_required = "Department Required" @@ -487,6 +508,15 @@ later = "Later" qr = "QR" title = "Title" +[ui.userfront.consent] +accept = "Agree and continue" +requested_scopes = "Requested permissions" +title = "Permission request" + +[ui.userfront.consent.cancel] +confirm_button = "Yes, cancel" +title = "Cancel consent" + [ui.userfront.nav] dashboard = "Dashboard" logout = "Logout" diff --git a/userfront/assets/translations/ko.toml b/userfront/assets/translations/ko.toml index 80b29c4b..792c7832 100644 --- a/userfront/assets/translations/ko.toml +++ b/userfront/assets/translations/ko.toml @@ -179,6 +179,27 @@ success = "로그인 승인에 성공했습니다." [msg.userfront.login_success] subtitle = "성공적으로 로그인되었습니다." +[msg.userfront.consent] +accept_error = "동의 처리에 실패했습니다: {error}" +client_id = "클라이언트 ID: {id}" +client_unknown = "알 수 없는 앱" +description = "아래 서비스가 회원님의 계정 정보에 접근하려고 합니다.\n계속 진행하려면 동의 여부를 선택해 주세요." +load_error = "동의 정보를 불러오는데 실패했습니다: {error}" +missing_redirect = "동의가 처리되었으나 리다이렉트 URL을 받지 못했습니다." +redirect_notice = "동의 후 자동으로 서비스로 이동합니다." +scope_count = "총 {count}개" + +[msg.userfront.consent.cancel] +confirm = "권한 동의를 취소하면 해당 서비스를 이용할 수 없습니다. 취소하시겠습니까?" +error = "취소 처리 중 오류가 발생했습니다: {error}" + +[msg.userfront.consent.scope] +email = "이메일 주소 (계정 식별 및 알림 용도)" +offline_access = "오프라인 접근 (로그인 유지)" +openid = "OpenID 인증 정보 (로그인 상태 확인)" +phone = "휴대폰 번호 (본인 인증 및 알림)" +profile = "기본 프로필 정보 (이름, 사용자 식별자)" + [msg.userfront.profile] department_missing = "소속 정보 없음" department_required = "소속을 입력해주세요." @@ -487,6 +508,15 @@ later = "나중에 하기 (대시보드로 이동)" qr = "QR 인증 (카메라 켜기)" title = "로그인 완료" +[ui.userfront.consent] +accept = "동의하고 계속하기" +requested_scopes = "요청된 권한" +title = "접근 권한 요청" + +[ui.userfront.consent.cancel] +confirm_button = "예, 취소합니다" +title = "동의 취소" + [ui.userfront.nav] dashboard = "대시보드" logout = "로그아웃" diff --git a/userfront/assets/translations/template.toml b/userfront/assets/translations/template.toml index 56e96f22..1c176ab5 100644 --- a/userfront/assets/translations/template.toml +++ b/userfront/assets/translations/template.toml @@ -173,6 +173,27 @@ success = "" [msg.userfront.login_success] subtitle = "" +[msg.userfront.consent] +accept_error = "" +client_id = "" +client_unknown = "" +description = "" +load_error = "" +missing_redirect = "" +redirect_notice = "" +scope_count = "" + +[msg.userfront.consent.cancel] +confirm = "" +error = "" + +[msg.userfront.consent.scope] +email = "" +offline_access = "" +openid = "" +phone = "" +profile = "" + [msg.userfront.profile] department_missing = "" department_required = "" @@ -481,6 +502,15 @@ later = "" qr = "" title = "" +[ui.userfront.consent] +accept = "" +requested_scopes = "" +title = "" + +[ui.userfront.consent.cancel] +confirm_button = "" +title = "" + [ui.userfront.nav] dashboard = "" logout = "" diff --git a/userfront/lib/features/auth/presentation/consent_screen.dart b/userfront/lib/features/auth/presentation/consent_screen.dart index 4d4f0734..9d7d8003 100644 --- a/userfront/lib/features/auth/presentation/consent_screen.dart +++ b/userfront/lib/features/auth/presentation/consent_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; +import 'package:userfront/i18n.dart'; 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'; @@ -19,27 +20,42 @@ class _ConsentScreenState extends State { bool _isSubmitting = false; String? _error; - // 사용자가 선택한 스코프 목록 final Set _selectedScopes = {}; - - // 권한별 설명 매핑 (동적으로 업데이트됨) - final Map _scopeDescriptions = { - 'openid': 'OpenID 인증 정보 (로그인 상태 확인)', - 'profile': '기본 프로필 정보 (이름, 사용자 식별자)', - 'email': '이메일 주소 (계정 식별 및 알림 용도)', - 'offline_access': '오프라인 접근 (로그인 유지)', - 'phone': '휴대폰 번호 (본인 인증 및 알림)', - }; - - // 필수 권한 목록 (동적으로 업데이트됨) + final Map _scopeDescriptions = {}; final Set _mandatoryScopes = {'openid'}; @override void initState() { super.initState(); + _scopeDescriptions.addAll(_defaultScopeDescriptions()); _fetchConsentInfo(); } + Map _defaultScopeDescriptions() { + return { + 'openid': tr( + 'msg.userfront.consent.scope.openid', + fallback: 'OpenID authentication information (signin session check)', + ), + 'profile': tr( + 'msg.userfront.consent.scope.profile', + fallback: 'Basic profile information (name, user identifier)', + ), + 'email': tr( + 'msg.userfront.consent.scope.email', + fallback: 'Email address (account identification and notifications)', + ), + 'offline_access': tr( + 'msg.userfront.consent.scope.offline_access', + fallback: 'Offline access (keep signed in)', + ), + 'phone': tr( + 'msg.userfront.consent.scope.phone', + fallback: 'Phone number (identity verification and notifications)', + ), + }; + } + Future _fetchConsentInfo() async { try { final info = await AuthProxyService.getConsentInfo( @@ -90,7 +106,11 @@ class _ConsentScreenState extends State { }); } catch (e) { setState(() { - _error = '동의 정보를 불러오는데 실패했습니다: $e'; + _error = tr( + 'msg.userfront.consent.load_error', + fallback: 'Failed to load consent information: {{error}}', + params: {'error': '$e'}, + ); _isLoading = false; }); } @@ -112,13 +132,21 @@ class _ConsentScreenState extends State { webWindow.redirectTo(result['redirectTo']); } else { setState(() { - _error = '동의가 처리되었으나, 리다이렉트 URL을 받지 못했습니다.'; + _error = tr( + 'msg.userfront.consent.missing_redirect', + fallback: + 'Consent was processed, but the redirect URL was missing.', + ); _isSubmitting = false; }); } } catch (e) { setState(() { - _error = '동의 처리에 실패했습니다: $e'; + _error = tr( + 'msg.userfront.consent.accept_error', + fallback: 'Failed to process consent: {{error}}', + params: {'error': '$e'}, + ); _isSubmitting = false; }); } @@ -128,17 +156,17 @@ class _ConsentScreenState extends State { final confirmed = await showDialog( context: context, builder: (context) => AlertDialog( - title: const Text('동의 취소'), - content: const Text('권한 동의를 취소하면 해당 서비스를 이용할 수 없습니다. 취소하시겠습니까?'), + title: Text(tr('ui.userfront.consent.cancel.title')), + content: Text(tr('msg.userfront.consent.cancel.confirm')), actions: [ TextButton( onPressed: () => Navigator.pop(context, false), - child: const Text('아니오'), + child: Text(tr('ui.common.cancel')), ), TextButton( onPressed: () => Navigator.pop(context, true), style: TextButton.styleFrom(foregroundColor: Colors.red), - child: const Text('예, 취소합니다'), + child: Text(tr('ui.userfront.consent.cancel.confirm_button')), ), ], ), @@ -159,9 +187,18 @@ class _ConsentScreenState extends State { } catch (e) { setState(() => _isSubmitting = false); if (mounted) { - ScaffoldMessenger.of( - context, - ).showSnackBar(SnackBar(content: Text('취소 처리 중 오류가 발생했습니다: $e'))); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + tr( + 'msg.userfront.consent.cancel.error', + fallback: + 'An error occurred while cancelling consent: {{error}}', + params: {'error': '$e'}, + ), + ), + ), + ); } } } @@ -200,7 +237,9 @@ class _ConsentScreenState extends State { } Widget _buildConsentCard(BuildContext context) { - final clientName = _consentInfo?['client']?['client_name'] ?? '알 수 없는 앱'; + final clientName = + _consentInfo?['client']?['client_name'] ?? + tr('msg.userfront.consent.client_unknown'); final clientId = _consentInfo?['client']?['client_id'] ?? '-'; final clientLogo = _consentInfo?['client']?['logo_uri']; final requestedScopes = @@ -223,14 +262,17 @@ class _ConsentScreenState extends State { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ // 1. 헤더 영역 - const Text( - '접근 권한 요청', - style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + Text( + tr('ui.userfront.consent.title'), + style: const TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + ), textAlign: TextAlign.center, ), const SizedBox(height: 12), Text( - '아래 서비스가 회원님의 계정 정보에 접근하려고 합니다.\n계속 진행하려면 동의 여부를 선택해 주세요.', + tr('msg.userfront.consent.description'), style: TextStyle(fontSize: 14, color: Colors.grey[600]), textAlign: TextAlign.center, ), @@ -277,7 +319,11 @@ class _ConsentScreenState extends State { ), const SizedBox(height: 4), Text( - '클라이언트 ID: $clientId', + tr( + 'msg.userfront.consent.client_id', + fallback: 'Client ID: {{id}}', + params: {'id': clientId}, + ), style: TextStyle( fontSize: 12, color: Colors.grey[500], @@ -296,15 +342,19 @@ class _ConsentScreenState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text( - '요청된 권한', - style: TextStyle( + Text( + tr('ui.userfront.consent.requested_scopes'), + style: const TextStyle( fontSize: 16, fontWeight: FontWeight.bold, ), ), Text( - '총 ${requestedScopes.length}개', + tr( + 'msg.userfront.consent.scope_count', + fallback: 'Total {{count}}', + params: {'count': '${requestedScopes.length}'}, + ), style: TextStyle( fontSize: 14, color: Theme.of(context).primaryColor, @@ -367,8 +417,8 @@ class _ConsentScreenState extends State { color: Colors.white, ), ) - : const Text( - '동의하고 계속하기', + : Text( + tr('ui.userfront.consent.accept'), style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, @@ -384,11 +434,11 @@ class _ConsentScreenState extends State { borderRadius: BorderRadius.circular(8), ), ), - child: const Text('취소'), + child: Text(tr('ui.common.cancel')), ), const SizedBox(height: 16), Text( - '동의 후 자동으로 서비스로 이동합니다.', + tr('msg.userfront.consent.redirect_notice'), style: TextStyle(fontSize: 12, color: Colors.grey[500]), textAlign: TextAlign.center, ),