forked from baron/baron-sso
feat: i18n 개선 및 userfront 로그인/로케일 보완
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
# Stage 1: Build Flutter
|
||||
FROM ghcr.io/cirruslabs/flutter:stable AS build
|
||||
FROM ghcr.io/cirruslabs/flutter:3.38.0 AS build
|
||||
ENV RUN_FLUTTER_AS_ROOT=true
|
||||
# ENV RUN_FLUTTER_AS_ROOT=true
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
# Get dependencies and build for web
|
||||
RUN /bin/sh ./scripts/sync_userfront_locales.sh
|
||||
WORKDIR /app/userfront
|
||||
RUN flutter pub get
|
||||
RUN touch .env
|
||||
RUN flutter build web --release --no-tree-shake-icons --wasm
|
||||
@@ -12,9 +13,9 @@ RUN flutter build web --release --no-tree-shake-icons --wasm
|
||||
# Stage 2: Serve with Nginx
|
||||
FROM nginx:alpine
|
||||
# Copy built assets
|
||||
COPY --from=build /app/build/web /usr/share/nginx/html
|
||||
COPY --from=build /app/userfront/build/web /usr/share/nginx/html
|
||||
# Copy custom Nginx config
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY userfront/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 5000
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
536
userfront/assets/translations/en.toml
Normal file
536
userfront/assets/translations/en.toml
Normal file
File diff suppressed because one or more lines are too long
536
userfront/assets/translations/ko.toml
Normal file
536
userfront/assets/translations/ko.toml
Normal file
File diff suppressed because one or more lines are too long
536
userfront/assets/translations/template.toml
Normal file
536
userfront/assets/translations/template.toml
Normal file
@@ -0,0 +1,536 @@
|
||||
[err.userfront]
|
||||
|
||||
[err.userfront.auth_proxy]
|
||||
consent_accept = ""
|
||||
consent_fetch = ""
|
||||
consent_reject = ""
|
||||
linked_app_revoke = ""
|
||||
login_failed = ""
|
||||
oidc_accept = ""
|
||||
password_reset_complete = ""
|
||||
password_reset_init = ""
|
||||
|
||||
[err.userfront.profile]
|
||||
load_failed = ""
|
||||
password_change_failed = ""
|
||||
send_code_failed = ""
|
||||
update_failed = ""
|
||||
verify_code_failed = ""
|
||||
|
||||
[err.userfront.session]
|
||||
missing = ""
|
||||
|
||||
[msg.userfront]
|
||||
greeting = ""
|
||||
|
||||
[msg.userfront.audit]
|
||||
date = ""
|
||||
device = ""
|
||||
end = ""
|
||||
ip = ""
|
||||
load_more_error = ""
|
||||
result = ""
|
||||
session_id = ""
|
||||
status = ""
|
||||
|
||||
[msg.userfront.dashboard]
|
||||
approved_device = ""
|
||||
approved_ip = ""
|
||||
audit_empty = ""
|
||||
audit_load_error = ""
|
||||
auth_method = ""
|
||||
client_id = ""
|
||||
client_id_missing = ""
|
||||
current_status = ""
|
||||
last_auth = ""
|
||||
link_missing = ""
|
||||
link_open_error = ""
|
||||
session_id_copied = ""
|
||||
|
||||
[msg.userfront.dashboard.activities]
|
||||
empty = ""
|
||||
empty_detail = ""
|
||||
error = ""
|
||||
|
||||
[msg.userfront.dashboard.approved_session]
|
||||
copy_click = ""
|
||||
copy_tap = ""
|
||||
none = ""
|
||||
|
||||
[msg.userfront.dashboard.revoke]
|
||||
confirm = ""
|
||||
error = ""
|
||||
success = ""
|
||||
|
||||
[msg.userfront.dashboard.scopes]
|
||||
empty = ""
|
||||
|
||||
[msg.userfront.dashboard.timeline]
|
||||
load_error = ""
|
||||
|
||||
[msg.userfront.error]
|
||||
detail_contact = ""
|
||||
detail_generic = ""
|
||||
detail_request = ""
|
||||
id = ""
|
||||
title = ""
|
||||
title_generic = ""
|
||||
title_with_code = ""
|
||||
type = ""
|
||||
|
||||
[msg.userfront.error.whitelist]
|
||||
settings_disabled = ""
|
||||
|
||||
[msg.userfront.forgot]
|
||||
description = ""
|
||||
dry_send = ""
|
||||
error = ""
|
||||
input_required = ""
|
||||
sent = ""
|
||||
|
||||
[msg.userfront.login]
|
||||
cookie_check_failed = ""
|
||||
dry_send = ""
|
||||
link_failed = ""
|
||||
link_send_failed = ""
|
||||
link_sent_email = ""
|
||||
link_sent_phone = ""
|
||||
link_timeout = ""
|
||||
no_account = ""
|
||||
oidc_failed = ""
|
||||
qr_expired = ""
|
||||
qr_init_failed = ""
|
||||
qr_login_required = ""
|
||||
token_missing = ""
|
||||
verification_failed = ""
|
||||
|
||||
[msg.userfront.login.link]
|
||||
approved = ""
|
||||
helper = ""
|
||||
missing_login_id = ""
|
||||
missing_phone = ""
|
||||
resend_wait = ""
|
||||
short_code_help = ""
|
||||
|
||||
[msg.userfront.login.password]
|
||||
failed = ""
|
||||
missing_credentials = ""
|
||||
|
||||
[msg.userfront.login.qr]
|
||||
load_failed = ""
|
||||
scan_hint = ""
|
||||
|
||||
[msg.userfront.login.short_code]
|
||||
invalid = ""
|
||||
|
||||
[msg.userfront.login.unregistered]
|
||||
body = ""
|
||||
|
||||
[msg.userfront.login.verification]
|
||||
approved = ""
|
||||
approved_local = ""
|
||||
success = ""
|
||||
|
||||
[msg.userfront.login_success]
|
||||
subtitle = ""
|
||||
|
||||
[msg.userfront.profile]
|
||||
department_missing = ""
|
||||
department_required = ""
|
||||
email_missing = ""
|
||||
greeting = ""
|
||||
load_failed = ""
|
||||
name_missing = ""
|
||||
name_required = ""
|
||||
phone_required = ""
|
||||
phone_verify_required = ""
|
||||
update_failed = ""
|
||||
update_success = ""
|
||||
|
||||
[msg.userfront.profile.password]
|
||||
change_failed = ""
|
||||
changed = ""
|
||||
current_required = ""
|
||||
mismatch = ""
|
||||
new_required = ""
|
||||
subtitle = ""
|
||||
|
||||
[msg.userfront.profile.phone]
|
||||
code_sent = ""
|
||||
send_failed = ""
|
||||
verified = ""
|
||||
verify_failed = ""
|
||||
verify_notice = ""
|
||||
|
||||
[msg.userfront.profile.section]
|
||||
basic = ""
|
||||
organization = ""
|
||||
security = ""
|
||||
|
||||
[msg.userfront.qr]
|
||||
approve_error = ""
|
||||
approve_success = ""
|
||||
camera_error = ""
|
||||
permission_error = ""
|
||||
permission_required = ""
|
||||
|
||||
[msg.userfront.reset]
|
||||
invalid_body = ""
|
||||
invalid_link = ""
|
||||
invalid_title = ""
|
||||
policy_loading = ""
|
||||
success = ""
|
||||
|
||||
[msg.userfront.reset.error]
|
||||
empty_password = ""
|
||||
generic = ""
|
||||
lowercase = ""
|
||||
min_length = ""
|
||||
min_types = ""
|
||||
mismatch = ""
|
||||
number = ""
|
||||
symbol = ""
|
||||
uppercase = ""
|
||||
|
||||
[msg.userfront.reset.policy]
|
||||
lowercase = ""
|
||||
min_length = ""
|
||||
min_types = ""
|
||||
number = ""
|
||||
symbol = ""
|
||||
uppercase = ""
|
||||
|
||||
[msg.userfront.sections]
|
||||
apps_subtitle = ""
|
||||
audit_subtitle = ""
|
||||
|
||||
[msg.userfront.settings]
|
||||
disabled = ""
|
||||
|
||||
[msg.userfront.signup]
|
||||
failed = ""
|
||||
privacy_full = ""
|
||||
tos_full = ""
|
||||
|
||||
[msg.userfront.signup.agreement]
|
||||
title = ""
|
||||
|
||||
[msg.userfront.signup.auth]
|
||||
affiliate_notice = ""
|
||||
title = ""
|
||||
|
||||
[msg.userfront.signup.email]
|
||||
code_mismatch = ""
|
||||
duplicate = ""
|
||||
invalid = ""
|
||||
send_failed = ""
|
||||
verified = ""
|
||||
verify_failed = ""
|
||||
|
||||
[msg.userfront.signup.password]
|
||||
length_required = ""
|
||||
lowercase_required = ""
|
||||
mismatch = ""
|
||||
number_required = ""
|
||||
symbol_required = ""
|
||||
title = ""
|
||||
uppercase_required = ""
|
||||
|
||||
[msg.userfront.signup.password.rule]
|
||||
lowercase = ""
|
||||
min_length = ""
|
||||
min_types = ""
|
||||
number = ""
|
||||
symbol = ""
|
||||
uppercase = ""
|
||||
|
||||
[msg.userfront.signup.phone]
|
||||
code_mismatch = ""
|
||||
send_failed = ""
|
||||
verified = ""
|
||||
verify_failed = ""
|
||||
|
||||
[msg.userfront.signup.policy]
|
||||
loading = ""
|
||||
lowercase = ""
|
||||
min_length = ""
|
||||
min_types = ""
|
||||
number = ""
|
||||
summary = ""
|
||||
symbol = ""
|
||||
uppercase = ""
|
||||
|
||||
[msg.userfront.signup.profile]
|
||||
affiliate_hint = ""
|
||||
title = ""
|
||||
|
||||
[msg.userfront.signup.success]
|
||||
body = ""
|
||||
title = ""
|
||||
|
||||
[ui.common]
|
||||
add = ""
|
||||
back = ""
|
||||
cancel = ""
|
||||
close = ""
|
||||
collapse = ""
|
||||
confirm = ""
|
||||
copy = ""
|
||||
create = ""
|
||||
delete = ""
|
||||
details = ""
|
||||
edit = ""
|
||||
hyphen = ""
|
||||
na = ""
|
||||
never = ""
|
||||
next = ""
|
||||
page_of = ""
|
||||
prev = ""
|
||||
previous = ""
|
||||
qr = ""
|
||||
read_only = ""
|
||||
refresh = ""
|
||||
requesting = ""
|
||||
resend = ""
|
||||
retry = ""
|
||||
save = ""
|
||||
search = ""
|
||||
show_more = ""
|
||||
language = ""
|
||||
language_ko = ""
|
||||
language_en = ""
|
||||
theme_dark = ""
|
||||
theme_light = ""
|
||||
theme_toggle = ""
|
||||
unknown = ""
|
||||
|
||||
[ui.common.badge]
|
||||
admin_only = ""
|
||||
command_only = ""
|
||||
system = ""
|
||||
|
||||
[ui.common.role]
|
||||
admin = ""
|
||||
user = ""
|
||||
|
||||
[ui.common.status]
|
||||
active = ""
|
||||
blocked = ""
|
||||
failure = ""
|
||||
inactive = ""
|
||||
ok = ""
|
||||
pending = ""
|
||||
success = ""
|
||||
|
||||
[ui.userfront]
|
||||
app_title = ""
|
||||
|
||||
[ui.userfront.app_label]
|
||||
admin_console = ""
|
||||
baron = ""
|
||||
dev_console = ""
|
||||
|
||||
[ui.userfront.audit]
|
||||
|
||||
[ui.userfront.audit.table]
|
||||
app = ""
|
||||
auth_method = ""
|
||||
date = ""
|
||||
device = ""
|
||||
ip = ""
|
||||
pending = ""
|
||||
result = ""
|
||||
session_id = ""
|
||||
status = ""
|
||||
|
||||
[ui.userfront.auth_method]
|
||||
ory = ""
|
||||
session = ""
|
||||
|
||||
[ui.userfront.dashboard]
|
||||
last_auth_label = ""
|
||||
status_history = ""
|
||||
|
||||
[ui.userfront.dashboard.activity]
|
||||
linked = ""
|
||||
|
||||
[ui.userfront.dashboard.approved_session]
|
||||
default = ""
|
||||
userfront = ""
|
||||
|
||||
[ui.userfront.dashboard.revoke]
|
||||
confirm_button = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.dashboard.scopes]
|
||||
title = ""
|
||||
|
||||
[ui.userfront.dashboard.status]
|
||||
revoked = ""
|
||||
|
||||
[ui.userfront.device]
|
||||
android = ""
|
||||
ios = ""
|
||||
linux = ""
|
||||
macos = ""
|
||||
windows = ""
|
||||
|
||||
[ui.userfront.error]
|
||||
go_home = ""
|
||||
go_login = ""
|
||||
|
||||
[ui.userfront.forgot]
|
||||
heading = ""
|
||||
input_label = ""
|
||||
submit = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.login]
|
||||
forgot_password = ""
|
||||
signup = ""
|
||||
|
||||
[ui.userfront.login.action]
|
||||
submit = ""
|
||||
|
||||
[ui.userfront.login.field]
|
||||
login_id = ""
|
||||
password = ""
|
||||
|
||||
[ui.userfront.login.link]
|
||||
action_label = ""
|
||||
code_only = ""
|
||||
page_title = ""
|
||||
resend_with_time = ""
|
||||
send = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.login.qr]
|
||||
expired = ""
|
||||
refresh = ""
|
||||
remaining = "Remaining: {time}"
|
||||
|
||||
[ui.userfront.login.short_code]
|
||||
digits = ""
|
||||
expire_time = ""
|
||||
prefix = ""
|
||||
submit = ""
|
||||
|
||||
[ui.userfront.login.tabs]
|
||||
link = ""
|
||||
password = ""
|
||||
qr = ""
|
||||
|
||||
[ui.userfront.login.unregistered]
|
||||
action = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.login.verification]
|
||||
action_label = ""
|
||||
page_title = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.login_success]
|
||||
later = ""
|
||||
qr = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.nav]
|
||||
dashboard = ""
|
||||
logout = ""
|
||||
profile = ""
|
||||
qr_scan = ""
|
||||
|
||||
[ui.userfront.profile]
|
||||
department_empty = ""
|
||||
manage = ""
|
||||
user_fallback = ""
|
||||
|
||||
[ui.userfront.profile.field]
|
||||
affiliation = ""
|
||||
company_code = ""
|
||||
department = ""
|
||||
email = ""
|
||||
name = ""
|
||||
tenant = ""
|
||||
|
||||
[ui.userfront.profile.password]
|
||||
change = ""
|
||||
confirm = ""
|
||||
current = ""
|
||||
forgot = ""
|
||||
new = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.profile.phone]
|
||||
code_hint = ""
|
||||
request_code = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.profile.section]
|
||||
basic = ""
|
||||
organization = ""
|
||||
security = ""
|
||||
|
||||
[ui.userfront.qr]
|
||||
request_permission = ""
|
||||
rescan = ""
|
||||
result_failure = ""
|
||||
result_success = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.reset]
|
||||
confirm_password = ""
|
||||
new_password = ""
|
||||
submit = ""
|
||||
subtitle = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.sections]
|
||||
apps = ""
|
||||
audit = ""
|
||||
|
||||
[ui.userfront.session]
|
||||
active = ""
|
||||
unknown = ""
|
||||
|
||||
[ui.userfront.signup]
|
||||
complete = ""
|
||||
next_step = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.signup.agreement]
|
||||
all = ""
|
||||
privacy_title = ""
|
||||
tos_title = ""
|
||||
|
||||
[ui.userfront.signup.auth]
|
||||
code_label = ""
|
||||
request_code = ""
|
||||
|
||||
[ui.userfront.signup.auth.email]
|
||||
label = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.signup.password]
|
||||
confirm_label = ""
|
||||
label = ""
|
||||
|
||||
[ui.userfront.signup.phone]
|
||||
label = ""
|
||||
title = ""
|
||||
|
||||
[ui.userfront.signup.profile]
|
||||
affiliation_type = ""
|
||||
company = ""
|
||||
department = ""
|
||||
department_optional = ""
|
||||
name = ""
|
||||
|
||||
[ui.userfront.signup.steps]
|
||||
agreement = ""
|
||||
password = ""
|
||||
profile = ""
|
||||
verify = ""
|
||||
|
||||
[ui.userfront.signup.success]
|
||||
action = ""
|
||||
51
userfront/lib/core/i18n/locale_gate.dart
Normal file
51
userfront/lib/core/i18n/locale_gate.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:easy_localization/easy_localization.dart' hide tr;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:userfront/i18n.dart';
|
||||
import '../services/web_window.dart';
|
||||
import 'locale_storage.dart';
|
||||
import 'locale_utils.dart';
|
||||
|
||||
class LocaleGate extends StatefulWidget {
|
||||
const LocaleGate({super.key, required this.localeCode, required this.child});
|
||||
|
||||
final String localeCode;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
State<LocaleGate> createState() => _LocaleGateState();
|
||||
}
|
||||
|
||||
class _LocaleGateState extends State<LocaleGate> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_applyLocale();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(LocaleGate oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.localeCode != widget.localeCode) {
|
||||
_applyLocale();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _applyLocale() async {
|
||||
final normalized = normalizeLocaleCode(widget.localeCode);
|
||||
LocaleStorage.write(normalized);
|
||||
webWindow.setTitle(
|
||||
tr('ui.userfront.app_title'),
|
||||
);
|
||||
if (context.locale.languageCode == normalized) {
|
||||
return;
|
||||
}
|
||||
await context.setLocale(Locale(normalized));
|
||||
webWindow.setTitle(
|
||||
tr('ui.userfront.app_title'),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => widget.child;
|
||||
}
|
||||
7
userfront/lib/core/i18n/locale_storage.dart
Normal file
7
userfront/lib/core/i18n/locale_storage.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
import 'locale_storage_stub.dart'
|
||||
if (dart.library.html) 'locale_storage_web.dart';
|
||||
|
||||
abstract class LocaleStorage {
|
||||
static String? read() => localeStorage.read();
|
||||
static void write(String locale) => localeStorage.write(locale);
|
||||
}
|
||||
11
userfront/lib/core/i18n/locale_storage_stub.dart
Normal file
11
userfront/lib/core/i18n/locale_storage_stub.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
class LocaleStorageImpl {
|
||||
String? _locale;
|
||||
|
||||
String? read() => _locale;
|
||||
|
||||
void write(String locale) {
|
||||
_locale = locale;
|
||||
}
|
||||
}
|
||||
|
||||
final localeStorage = LocaleStorageImpl();
|
||||
120
userfront/lib/core/i18n/locale_storage_web.dart
Normal file
120
userfront/lib/core/i18n/locale_storage_web.dart
Normal file
@@ -0,0 +1,120 @@
|
||||
// ignore_for_file: avoid_web_libraries_in_flutter
|
||||
|
||||
import 'dart:html' as html;
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class LocaleStorageImpl {
|
||||
static const _key = 'locale';
|
||||
static const _legacyKey = 'baron_locale';
|
||||
static final Map<String, String> _memory = {};
|
||||
static bool _forceMemory = false;
|
||||
static bool _forceSession = false;
|
||||
|
||||
@visibleForTesting
|
||||
static void forceMemoryStorageForTests(bool value) {
|
||||
_forceMemory = value;
|
||||
if (!value) {
|
||||
_memory.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
static void forceSessionStorageForTests(bool value) {
|
||||
_forceSession = value;
|
||||
}
|
||||
|
||||
String? _read(String key) {
|
||||
if (!_forceMemory && !_forceSession) {
|
||||
try {
|
||||
return html.window.localStorage[key];
|
||||
} catch (_) {
|
||||
// localStorage 접근이 차단된 경우 sessionStorage로 fallback.
|
||||
try {
|
||||
return html.window.sessionStorage[key];
|
||||
} catch (_) {
|
||||
// sessionStorage도 차단된 경우 메모리 fallback 사용.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_forceMemory) {
|
||||
try {
|
||||
return html.window.sessionStorage[key];
|
||||
} catch (_) {
|
||||
// sessionStorage도 차단된 경우 메모리 fallback 사용.
|
||||
}
|
||||
}
|
||||
return _memory[key];
|
||||
}
|
||||
|
||||
void _write(String key, String value) {
|
||||
if (!_forceMemory && !_forceSession) {
|
||||
try {
|
||||
html.window.localStorage[key] = value;
|
||||
return;
|
||||
} catch (_) {
|
||||
// localStorage 접근이 차단된 경우 sessionStorage로 fallback.
|
||||
try {
|
||||
html.window.sessionStorage[key] = value;
|
||||
return;
|
||||
} catch (_) {
|
||||
// sessionStorage도 차단된 경우 메모리 fallback 사용.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_forceMemory) {
|
||||
try {
|
||||
html.window.sessionStorage[key] = value;
|
||||
return;
|
||||
} catch (_) {
|
||||
// sessionStorage도 차단된 경우 메모리 fallback 사용.
|
||||
}
|
||||
}
|
||||
_memory[key] = value;
|
||||
}
|
||||
|
||||
void _remove(String key) {
|
||||
if (!_forceMemory && !_forceSession) {
|
||||
try {
|
||||
html.window.localStorage.remove(key);
|
||||
return;
|
||||
} catch (_) {
|
||||
// localStorage 접근이 차단된 경우 sessionStorage로 fallback.
|
||||
try {
|
||||
html.window.sessionStorage.remove(key);
|
||||
return;
|
||||
} catch (_) {
|
||||
// sessionStorage도 차단된 경우 메모리 fallback 사용.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_forceMemory) {
|
||||
try {
|
||||
html.window.sessionStorage.remove(key);
|
||||
return;
|
||||
} catch (_) {
|
||||
// sessionStorage도 차단된 경우 메모리 fallback 사용.
|
||||
}
|
||||
}
|
||||
_memory.remove(key);
|
||||
}
|
||||
|
||||
String? read() {
|
||||
final current = _read(_key);
|
||||
if (current != null && current.isNotEmpty) {
|
||||
return current;
|
||||
}
|
||||
final legacy = _read(_legacyKey);
|
||||
if (legacy != null && legacy.isNotEmpty) {
|
||||
_write(_key, legacy);
|
||||
_remove(_legacyKey);
|
||||
return legacy;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void write(String locale) {
|
||||
_write(_key, locale);
|
||||
}
|
||||
}
|
||||
|
||||
final localeStorage = LocaleStorageImpl();
|
||||
69
userfront/lib/core/i18n/locale_utils.dart
Normal file
69
userfront/lib/core/i18n/locale_utils.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'locale_storage.dart';
|
||||
|
||||
const supportedLocaleCodes = ['en', 'ko'];
|
||||
const defaultLocaleCode = 'en';
|
||||
|
||||
String normalizeLocaleCode(String? code) {
|
||||
if (code == null || code.isEmpty) {
|
||||
return defaultLocaleCode;
|
||||
}
|
||||
final normalized = code.toLowerCase();
|
||||
if (normalized == 'ko' || normalized.startsWith('ko-')) {
|
||||
return 'ko';
|
||||
}
|
||||
if (normalized == 'en' || normalized.startsWith('en-')) {
|
||||
return 'en';
|
||||
}
|
||||
return defaultLocaleCode;
|
||||
}
|
||||
|
||||
String resolvePreferredLocaleCode() {
|
||||
final stored = LocaleStorage.read();
|
||||
if (stored != null && supportedLocaleCodes.contains(stored)) {
|
||||
return stored;
|
||||
}
|
||||
final deviceLocale = PlatformDispatcher.instance.locale;
|
||||
return normalizeLocaleCode(deviceLocale.languageCode);
|
||||
}
|
||||
|
||||
String? extractLocaleFromPath(Uri uri) {
|
||||
if (uri.pathSegments.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
final code = uri.pathSegments.first.toLowerCase();
|
||||
if (supportedLocaleCodes.contains(code)) {
|
||||
return code;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String stripLocalePath(Uri uri) {
|
||||
final segments = uri.pathSegments;
|
||||
if (segments.isNotEmpty && supportedLocaleCodes.contains(segments.first)) {
|
||||
final rest = segments.skip(1).join('/');
|
||||
if (rest.isEmpty) {
|
||||
return '/';
|
||||
}
|
||||
return '/$rest';
|
||||
}
|
||||
return uri.path;
|
||||
}
|
||||
|
||||
String buildLocalizedPath(String localeCode, Uri uri) {
|
||||
final segments = uri.pathSegments;
|
||||
Iterable<String> restSegments = segments;
|
||||
if (segments.isNotEmpty) {
|
||||
final head = segments.first.toLowerCase();
|
||||
if (supportedLocaleCodes.contains(head) || head.length == 2) {
|
||||
restSegments = segments.skip(1);
|
||||
}
|
||||
}
|
||||
final newSegments = [localeCode, ...restSegments];
|
||||
final path = '/${newSegments.join('/')}';
|
||||
if (uri.queryParameters.isEmpty) {
|
||||
return path;
|
||||
}
|
||||
return Uri(path: path, queryParameters: uri.queryParameters).toString();
|
||||
}
|
||||
22
userfront/lib/core/i18n/toml_asset_loader.dart
Normal file
22
userfront/lib/core/i18n/toml_asset_loader.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:toml/toml.dart';
|
||||
|
||||
class TomlAssetLoader extends AssetLoader {
|
||||
const TomlAssetLoader();
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> load(String path, Locale locale) async {
|
||||
final assetPath = '$path/${locale.languageCode}.toml';
|
||||
try {
|
||||
final content = await rootBundle.loadString(assetPath);
|
||||
final document = TomlDocument.parse(content);
|
||||
return document.toMap();
|
||||
} catch (e) {
|
||||
// 로딩 실패 시 빈 맵을 반환해 렌더링을 지속합니다.
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,18 +11,34 @@ class AuthProxyService {
|
||||
if (!dotenv.isInitialized) {
|
||||
return fallback;
|
||||
}
|
||||
return dotenv.env[key] ?? fallback;
|
||||
final value = dotenv.env[key];
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return fallback;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static String _fallbackOrigin() {
|
||||
try {
|
||||
final origin = Uri.base.origin;
|
||||
if (origin.isNotEmpty && origin != 'null') {
|
||||
return origin;
|
||||
}
|
||||
} catch (_) {}
|
||||
return 'http://sso.hmac.kr';
|
||||
}
|
||||
|
||||
static String get _baseUrl {
|
||||
final rawUrl = _envOrDefault('BACKEND_URL', 'https://sso.hmac.kr');
|
||||
final rawUrl = _envOrDefault('BACKEND_URL', _fallbackOrigin());
|
||||
// 배포 환경에서 $ 기호나 공백이 섞여 들어오는 경우를 방지하기 위해 정제합니다.
|
||||
return rawUrl.replaceAll(r'$', '').trim().replaceAll(RegExp(r'/$'), '');
|
||||
}
|
||||
|
||||
static bool get _isProd {
|
||||
final env = _envOrDefault('APP_ENV', 'dev').toLowerCase();
|
||||
return env == 'prod' || env == 'production';
|
||||
}
|
||||
|
||||
static bool get isProdEnv => _isProd;
|
||||
static bool _shouldSendDrySend(bool? drySend) {
|
||||
if (_isProd) {
|
||||
@@ -76,13 +92,14 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<int> getSessionStatus({String? token, bool useCookie = false}) async {
|
||||
static Future<int> getSessionStatus({
|
||||
String? token,
|
||||
bool useCookie = false,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/user/me');
|
||||
final client = createHttpClient(withCredentials: useCookie);
|
||||
try {
|
||||
final headers = <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
final headers = <String, String>{'Content-Type': 'application/json'};
|
||||
if (!useCookie && token != null && token.isNotEmpty) {
|
||||
headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
@@ -100,12 +117,9 @@ class AuthProxyService {
|
||||
bool? drySend,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/enchanted-link/init');
|
||||
final userfrontUrl = _envOrDefault('USERFRONT_URL', 'http://sso.hmac.kr');
|
||||
|
||||
final body = <String, dynamic>{
|
||||
'loginId': loginId,
|
||||
'uri': userfrontUrl,
|
||||
};
|
||||
final userfrontUrl = _envOrDefault('USERFRONT_URL', _fallbackOrigin());
|
||||
|
||||
final body = <String, dynamic>{'loginId': loginId, 'uri': userfrontUrl};
|
||||
if (_shouldSendDrySend(drySend)) {
|
||||
body['drySend'] = true;
|
||||
}
|
||||
@@ -115,7 +129,7 @@ class AuthProxyService {
|
||||
if (codeOnly == true) {
|
||||
body['codeOnly'] = true;
|
||||
}
|
||||
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
@@ -133,15 +147,15 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> pollEnchantedLink(String pendingRef) async {
|
||||
static Future<Map<String, dynamic>> pollEnchantedLink(
|
||||
String pendingRef,
|
||||
) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/enchanted-link/poll');
|
||||
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'pendingRef': pendingRef,
|
||||
}),
|
||||
body: jsonEncode({'pendingRef': pendingRef}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@@ -157,16 +171,16 @@ class AuthProxyService {
|
||||
);
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> verifyMagicLink(String token, {bool verifyOnly = false}) async {
|
||||
static Future<Map<String, dynamic>> verifyMagicLink(
|
||||
String token, {
|
||||
bool verifyOnly = false,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/magic-link/verify');
|
||||
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'token': token,
|
||||
'verifyOnly': verifyOnly,
|
||||
}),
|
||||
body: jsonEncode({'token': token, 'verifyOnly': verifyOnly}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@@ -223,10 +237,7 @@ class AuthProxyService {
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'shortCode': shortCode,
|
||||
'verifyOnly': verifyOnly,
|
||||
}),
|
||||
body: jsonEncode({'shortCode': shortCode, 'verifyOnly': verifyOnly}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@@ -240,13 +251,18 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> loginWithPassword(String loginId, String password, {String? loginChallenge}) async {
|
||||
static Future<Map<String, dynamic>> loginWithPassword(
|
||||
String loginId,
|
||||
String password, {
|
||||
String? loginChallenge,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/password/login');
|
||||
|
||||
|
||||
final payload = {
|
||||
'loginId': loginId,
|
||||
'password': password,
|
||||
if (loginChallenge != null && loginChallenge.isNotEmpty) 'login_challenge': loginChallenge,
|
||||
if (loginChallenge != null && loginChallenge.isNotEmpty)
|
||||
'login_challenge': loginChallenge,
|
||||
};
|
||||
|
||||
final response = await http.post(
|
||||
@@ -267,13 +283,17 @@ class AuthProxyService {
|
||||
errorBody['error'] ??
|
||||
tr(
|
||||
'err.userfront.auth_proxy.login_failed',
|
||||
fallback: '로그인에 실패했습니다.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
static Future<Map<String, dynamic>> getConsentInfo(String consentChallenge) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/consent').replace(queryParameters: {'consent_challenge': consentChallenge});
|
||||
|
||||
static Future<Map<String, dynamic>> getConsentInfo(
|
||||
String consentChallenge,
|
||||
) async {
|
||||
final url = Uri.parse(
|
||||
'$_baseUrl/api/v1/auth/consent',
|
||||
).replace(queryParameters: {'consent_challenge': consentChallenge});
|
||||
final response = await http.get(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
@@ -287,17 +307,17 @@ class AuthProxyService {
|
||||
errorBody['error'] ??
|
||||
tr(
|
||||
'err.userfront.auth_proxy.consent_fetch',
|
||||
fallback: '동의 정보를 가져오지 못했습니다.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> acceptConsent(String consentChallenge, {List<String>? grantScope}) async {
|
||||
static Future<Map<String, dynamic>> acceptConsent(
|
||||
String consentChallenge, {
|
||||
List<String>? grantScope,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/consent/accept');
|
||||
final body = <String, dynamic>{
|
||||
'consent_challenge': consentChallenge,
|
||||
};
|
||||
final body = <String, dynamic>{'consent_challenge': consentChallenge};
|
||||
if (grantScope != null) {
|
||||
body['grant_scope'] = grantScope;
|
||||
}
|
||||
@@ -316,17 +336,16 @@ class AuthProxyService {
|
||||
errorBody['error'] ??
|
||||
tr(
|
||||
'err.userfront.auth_proxy.consent_accept',
|
||||
fallback: '동의 처리에 실패했습니다.',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> rejectConsent(String consentChallenge) async {
|
||||
static Future<Map<String, dynamic>> rejectConsent(
|
||||
String consentChallenge,
|
||||
) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/consent/reject');
|
||||
final body = <String, dynamic>{
|
||||
'consent_challenge': consentChallenge,
|
||||
};
|
||||
final body = <String, dynamic>{'consent_challenge': consentChallenge};
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
@@ -342,7 +361,6 @@ class AuthProxyService {
|
||||
errorBody['error'] ??
|
||||
tr(
|
||||
'err.userfront.auth_proxy.consent_reject',
|
||||
fallback: '동의 거부에 실패했습니다.',
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -353,9 +371,7 @@ class AuthProxyService {
|
||||
String? token,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/oidc/login/accept');
|
||||
final headers = <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
final headers = <String, String>{'Content-Type': 'application/json'};
|
||||
if (token != null && token.isNotEmpty) {
|
||||
headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
@@ -364,9 +380,7 @@ class AuthProxyService {
|
||||
final response = await client.post(
|
||||
url,
|
||||
headers: headers,
|
||||
body: jsonEncode({
|
||||
'login_challenge': loginChallenge,
|
||||
}),
|
||||
body: jsonEncode({'login_challenge': loginChallenge}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@@ -377,7 +391,6 @@ class AuthProxyService {
|
||||
errorBody['error'] ??
|
||||
tr(
|
||||
'err.userfront.auth_proxy.oidc_accept',
|
||||
fallback: 'OIDC 로그인 승인에 실패했습니다.',
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -386,8 +399,10 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Future<Map<String, dynamic>> initiatePasswordReset(String loginId, {bool? drySend}) async {
|
||||
static Future<Map<String, dynamic>> initiatePasswordReset(
|
||||
String loginId, {
|
||||
bool? drySend,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/password/reset/initiate');
|
||||
final response = await http.post(
|
||||
url,
|
||||
@@ -406,7 +421,6 @@ class AuthProxyService {
|
||||
errorBody['error'] ??
|
||||
tr(
|
||||
'err.userfront.auth_proxy.password_reset_init',
|
||||
fallback: '비밀번호 재설정을 시작하지 못했습니다.',
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -424,7 +438,9 @@ class AuthProxyService {
|
||||
if (token != null && token.isNotEmpty) {
|
||||
query['token'] = token;
|
||||
}
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/password/reset/complete').replace(queryParameters: query);
|
||||
final url = Uri.parse(
|
||||
'$_baseUrl/api/v1/auth/password/reset/complete',
|
||||
).replace(queryParameters: query);
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
@@ -439,7 +455,6 @@ class AuthProxyService {
|
||||
errorBody['error'] ??
|
||||
tr(
|
||||
'err.userfront.auth_proxy.password_reset_complete',
|
||||
fallback: '비밀번호 재설정에 실패했습니다.',
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -447,13 +462,11 @@ class AuthProxyService {
|
||||
|
||||
static Future<void> sendSms(String phoneNumber) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/sms');
|
||||
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'phoneNumber': phoneNumber,
|
||||
}),
|
||||
body: jsonEncode({'phoneNumber': phoneNumber}),
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
@@ -465,16 +478,16 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> verifySmsCode(String phoneNumber, String code) async {
|
||||
static Future<Map<String, dynamic>> verifySmsCode(
|
||||
String phoneNumber,
|
||||
String code,
|
||||
) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/verify-sms');
|
||||
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'phoneNumber': phoneNumber,
|
||||
'code': code,
|
||||
}),
|
||||
body: jsonEncode({'phoneNumber': phoneNumber, 'code': code}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@@ -532,10 +545,10 @@ class AuthProxyService {
|
||||
String? token,
|
||||
bool withCredentials = false,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/qr/approve'); // Mapping to ScanQRLogin on backend
|
||||
final payload = <String, dynamic>{
|
||||
'pendingRef': pendingRef,
|
||||
};
|
||||
final url = Uri.parse(
|
||||
'$_baseUrl/api/v1/auth/qr/approve',
|
||||
); // Mapping to ScanQRLogin on backend
|
||||
final payload = <String, dynamic>{'pendingRef': pendingRef};
|
||||
if (token != null && token.isNotEmpty) {
|
||||
payload['token'] = token;
|
||||
}
|
||||
@@ -593,7 +606,7 @@ class AuthProxyService {
|
||||
String? displayName,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/admin/users');
|
||||
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {
|
||||
@@ -617,7 +630,10 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<List<dynamic>> listUsers(String adminPassword, {String? query}) async {
|
||||
static Future<List<dynamic>> listUsers(
|
||||
String adminPassword, {
|
||||
String? query,
|
||||
}) async {
|
||||
var uri = Uri.parse('$_baseUrl/api/v1/admin/users');
|
||||
if (query != null && query.isNotEmpty) {
|
||||
uri = uri.replace(queryParameters: {'text': query});
|
||||
@@ -646,7 +662,7 @@ class AuthProxyService {
|
||||
static Future<void> deleteUser(String adminPassword, String loginId) async {
|
||||
final encodedId = Uri.encodeComponent(loginId);
|
||||
final url = Uri.parse('$_baseUrl/api/v1/admin/users/$encodedId');
|
||||
|
||||
|
||||
final response = await http.delete(
|
||||
url,
|
||||
headers: {
|
||||
@@ -664,10 +680,14 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> updateUserStatus(String adminPassword, String loginId, String status) async {
|
||||
static Future<void> updateUserStatus(
|
||||
String adminPassword,
|
||||
String loginId,
|
||||
String status,
|
||||
) async {
|
||||
final encodedId = Uri.encodeComponent(loginId);
|
||||
final url = Uri.parse('$_baseUrl/api/v1/admin/users/$encodedId/status');
|
||||
|
||||
|
||||
final response = await http.patch(
|
||||
url,
|
||||
headers: {
|
||||
@@ -695,7 +715,7 @@ class AuthProxyService {
|
||||
}) async {
|
||||
final encodedId = Uri.encodeComponent(loginId);
|
||||
final url = Uri.parse('$_baseUrl/api/v1/admin/users/$encodedId');
|
||||
|
||||
|
||||
final body = <String, dynamic>{};
|
||||
if (email != null) body['email'] = email;
|
||||
if (phone != null) body['phone'] = phone;
|
||||
@@ -725,18 +745,13 @@ class AuthProxyService {
|
||||
final token = AuthTokenStore.getToken();
|
||||
|
||||
final client = createHttpClient(withCredentials: useCookie);
|
||||
final headers = <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
final headers = <String, String>{'Content-Type': 'application/json'};
|
||||
if (!useCookie && token != null) {
|
||||
headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
|
||||
try {
|
||||
final response = await client.get(
|
||||
url,
|
||||
headers: headers,
|
||||
);
|
||||
final response = await client.get(url, headers: headers);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final data = jsonDecode(response.body);
|
||||
@@ -758,18 +773,13 @@ class AuthProxyService {
|
||||
final token = AuthTokenStore.getToken();
|
||||
|
||||
final client = createHttpClient(withCredentials: useCookie);
|
||||
final headers = <String, String>{
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
final headers = <String, String>{'Content-Type': 'application/json'};
|
||||
if (!useCookie && token != null) {
|
||||
headers['Authorization'] = 'Bearer $token';
|
||||
}
|
||||
|
||||
try {
|
||||
final response = await client.delete(
|
||||
url,
|
||||
headers: headers,
|
||||
);
|
||||
final response = await client.delete(url, headers: headers);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
final errorBody = jsonDecode(response.body);
|
||||
@@ -777,7 +787,6 @@ class AuthProxyService {
|
||||
errorBody['error'] ??
|
||||
tr(
|
||||
'err.userfront.auth_proxy.linked_app_revoke',
|
||||
fallback: '연동 해지에 실패했습니다.',
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -786,7 +795,11 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> sendLog(String level, String message, {Map<String, dynamic>? data}) async {
|
||||
static Future<void> sendLog(
|
||||
String level,
|
||||
String message, {
|
||||
Map<String, dynamic>? data,
|
||||
}) async {
|
||||
if (!_canSendClientLog()) {
|
||||
return;
|
||||
}
|
||||
@@ -808,11 +821,15 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> logError(String message, {dynamic error, StackTrace? stackTrace}) async {
|
||||
static Future<void> logError(
|
||||
String message, {
|
||||
dynamic error,
|
||||
StackTrace? stackTrace,
|
||||
}) async {
|
||||
final data = <String, dynamic>{};
|
||||
if (error != null) data['error'] = error.toString();
|
||||
if (stackTrace != null) data['stack'] = stackTrace.toString();
|
||||
|
||||
|
||||
await sendLog('ERROR', message, data: data);
|
||||
}
|
||||
|
||||
@@ -861,7 +878,7 @@ class AuthProxyService {
|
||||
static Future<void> sendSignupCode(String target, String type) async {
|
||||
final path = type == 'email' ? 'send-email-code' : 'send-sms-code';
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/signup/$path');
|
||||
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
@@ -877,17 +894,17 @@ class AuthProxyService {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> verifySignupCode(String target, String type, String code) async {
|
||||
static Future<bool> verifySignupCode(
|
||||
String target,
|
||||
String type,
|
||||
String code,
|
||||
) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/signup/verify-code');
|
||||
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'target': target,
|
||||
'type': type,
|
||||
'code': code,
|
||||
}),
|
||||
body: jsonEncode({'target': target, 'type': type, 'code': code}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@@ -908,7 +925,7 @@ class AuthProxyService {
|
||||
required bool termsAccepted,
|
||||
}) async {
|
||||
final url = Uri.parse('$_baseUrl/api/v1/auth/signup');
|
||||
|
||||
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class WebWindow {
|
||||
void setTitle(String title) {}
|
||||
|
||||
void redirectTo(String url) {}
|
||||
|
||||
void alert(String message) {}
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
import 'dart:html' as html;
|
||||
|
||||
class WebWindow {
|
||||
void setTitle(String title) {
|
||||
html.document.title = title;
|
||||
}
|
||||
|
||||
void redirectTo(String url) {
|
||||
html.window.location.href = url;
|
||||
}
|
||||
|
||||
65
userfront/lib/core/widgets/language_selector.dart
Normal file
65
userfront/lib/core/widgets/language_selector.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:easy_localization/easy_localization.dart' hide tr;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:userfront/i18n.dart';
|
||||
|
||||
import '../i18n/locale_storage.dart';
|
||||
import '../i18n/locale_utils.dart';
|
||||
|
||||
class LanguageSelector extends StatelessWidget {
|
||||
const LanguageSelector({super.key, this.compact = false});
|
||||
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final current = context.locale.languageCode;
|
||||
final items = [
|
||||
DropdownMenuItem(
|
||||
value: 'ko',
|
||||
child: Text(tr('ui.common.language_ko')),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'en',
|
||||
child: Text(tr('ui.common.language_en', fallback: 'English')),
|
||||
),
|
||||
];
|
||||
|
||||
final iconSize = compact ? 16.0 : 18.0;
|
||||
final dropdown = DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
value: current,
|
||||
items: items,
|
||||
isDense: true,
|
||||
icon: Icon(Icons.arrow_drop_down, size: compact ? 18 : 20),
|
||||
onChanged: (value) async {
|
||||
if (value == null || value == current) {
|
||||
return;
|
||||
}
|
||||
LocaleStorage.write(value);
|
||||
await context.setLocale(Locale(value));
|
||||
final uri = GoRouterState.of(context).uri;
|
||||
final target = buildLocalizedPath(value, uri);
|
||||
if (context.mounted) {
|
||||
context.go(target);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(top: compact ? 0 : 2),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minHeight: compact ? 24 : 28),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.language, size: iconSize),
|
||||
const SizedBox(width: 6),
|
||||
dropdown,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -30,32 +30,33 @@ class ErrorScreen extends StatelessWidget {
|
||||
? (isWhitelisted && hasCode ? normalizedCode : 'unknown_error')
|
||||
: (hasCode ? normalizedCode : 'unknown_error');
|
||||
final title = isProd
|
||||
? tr('msg.userfront.error.title', fallback: '인증 과정에서 오류가 발생했습니다')
|
||||
? tr('msg.userfront.error.title')
|
||||
: (hasCode
|
||||
? tr(
|
||||
'msg.userfront.error.title_with_code',
|
||||
fallback: '오류: {{code}}',
|
||||
params: {'code': normalizedCode},
|
||||
)
|
||||
: tr('msg.userfront.error.title_generic', fallback: '오류가 발생했습니다'));
|
||||
? tr(
|
||||
'msg.userfront.error.title_with_code',
|
||||
params: {'code': normalizedCode},
|
||||
)
|
||||
: tr(
|
||||
'msg.userfront.error.title_generic',
|
||||
));
|
||||
final detail = isProd
|
||||
? (isWhitelisted
|
||||
? tr(
|
||||
'msg.userfront.error.whitelist.$normalizedCode',
|
||||
fallback: whitelistFallback,
|
||||
)
|
||||
: tr(
|
||||
'msg.userfront.error.detail_contact',
|
||||
fallback: '에러가 계속되면 관리자에게 문의해주세요',
|
||||
))
|
||||
? tr(
|
||||
'msg.userfront.error.whitelist.$normalizedCode',
|
||||
fallback: whitelistFallback,
|
||||
)
|
||||
: tr(
|
||||
'msg.userfront.error.detail_contact',
|
||||
))
|
||||
: ((description?.isNotEmpty == true)
|
||||
? description!
|
||||
: (hasCode
|
||||
? tr('msg.userfront.error.detail_generic', fallback: '오류가 발생했습니다.')
|
||||
: tr(
|
||||
'msg.userfront.error.detail_request',
|
||||
fallback: '요청을 처리하는 중 문제가 발생했습니다.',
|
||||
)));
|
||||
? description!
|
||||
: (hasCode
|
||||
? tr(
|
||||
'msg.userfront.error.detail_generic',
|
||||
)
|
||||
: tr(
|
||||
'msg.userfront.error.detail_request',
|
||||
)));
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF7F8FA),
|
||||
@@ -94,7 +95,6 @@ class ErrorScreen extends StatelessWidget {
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.error.type',
|
||||
fallback: '오류 종류: {{type}}',
|
||||
params: {'type': errorType},
|
||||
),
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
@@ -106,7 +106,6 @@ class ErrorScreen extends StatelessWidget {
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.error.id',
|
||||
fallback: '오류 ID: {{id}}',
|
||||
params: {'id': errorId!},
|
||||
),
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
@@ -124,27 +123,35 @@ class ErrorScreen extends StatelessWidget {
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF111827),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
tr('ui.userfront.error.go_login', fallback: '로그인으로 이동'),
|
||||
tr(
|
||||
'ui.userfront.error.go_login',
|
||||
),
|
||||
),
|
||||
),
|
||||
OutlinedButton(
|
||||
onPressed: () => context.go('/'),
|
||||
style: OutlinedButton.styleFrom(
|
||||
foregroundColor: const Color(0xFF111827),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
side: const BorderSide(color: Color(0xFFCBD5F5)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
tr('ui.userfront.error.go_home', fallback: '홈으로 이동'),
|
||||
tr('ui.userfront.error.go_home'),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -17,7 +17,9 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_drySendEnabled = _parseBoolParam(Uri.base.queryParameters['drySend']) && !AuthProxyService.isProdEnv;
|
||||
_drySendEnabled =
|
||||
_parseBoolParam(Uri.base.queryParameters['drySend']) &&
|
||||
!AuthProxyService.isProdEnv;
|
||||
}
|
||||
|
||||
Future<void> _handlePasswordReset() async {
|
||||
@@ -26,7 +28,6 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||
_showError(
|
||||
tr(
|
||||
'msg.userfront.forgot.input_required',
|
||||
fallback: '이메일 또는 휴대폰 번호를 입력해주세요.',
|
||||
),
|
||||
);
|
||||
return;
|
||||
@@ -44,14 +45,16 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
try {
|
||||
await AuthProxyService.initiatePasswordReset(loginId, drySend: _drySendEnabled);
|
||||
await AuthProxyService.initiatePasswordReset(
|
||||
loginId,
|
||||
drySend: _drySendEnabled,
|
||||
);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.forgot.sent',
|
||||
fallback: '비밀번호 재설정 링크가 전송되었습니다. 이메일 또는 SMS를 확인해주세요.',
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.green,
|
||||
@@ -64,7 +67,6 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||
_showError(
|
||||
tr(
|
||||
'msg.userfront.forgot.error',
|
||||
fallback: '전송에 실패했습니다: {{error}}',
|
||||
params: {'error': e.toString()},
|
||||
),
|
||||
);
|
||||
@@ -94,7 +96,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(tr('ui.userfront.forgot.title', fallback: '비밀번호 재설정')),
|
||||
title: Text(tr('ui.userfront.forgot.title')),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Center(
|
||||
@@ -106,17 +108,17 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
tr('ui.userfront.forgot.heading', fallback: '비밀번호를 잊으셨나요?'),
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
tr('ui.userfront.forgot.heading'),
|
||||
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
if (_drySendEnabled) ...[
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFF3CD),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@@ -124,15 +126,20 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.warning_amber_rounded, color: Color(0xFF8A6D3B)),
|
||||
const Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
color: Color(0xFF8A6D3B),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
tr(
|
||||
'msg.userfront.forgot.dry_send',
|
||||
fallback: 'drySend 모드: 실제 이메일/SMS는 발송되지 않습니다.',
|
||||
),
|
||||
style: const TextStyle(color: Color(0xFF8A6D3B), fontSize: 12),
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF8A6D3B),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -143,8 +150,6 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.forgot.description',
|
||||
fallback:
|
||||
'계정과 연결된 이메일 주소 또는 휴대폰 번호를 입력하시면, 비밀번호를 재설정할 수 있는 링크를 보내드립니다.',
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(color: Colors.grey),
|
||||
@@ -155,7 +160,6 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.forgot.input_label',
|
||||
fallback: '이메일 또는 휴대폰 번호',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.person_outline),
|
||||
@@ -172,13 +176,13 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
tr(
|
||||
'ui.userfront.forgot.submit',
|
||||
fallback: '재설정 링크 전송',
|
||||
),
|
||||
tr('ui.userfront.forgot.submit'),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,23 +14,26 @@ class LoginSuccessScreen extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.check_circle_outline, size: 80, color: Colors.green),
|
||||
const Icon(
|
||||
Icons.check_circle_outline,
|
||||
size: 80,
|
||||
color: Colors.green,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
tr('ui.userfront.login_success.title', fallback: '로그인 완료'),
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
tr('ui.userfront.login_success.title'),
|
||||
style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
tr('msg.userfront.login_success.subtitle', fallback: '성공적으로 로그인되었습니다.'),
|
||||
tr(
|
||||
'msg.userfront.login_success.subtitle',
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(color: Colors.grey, fontSize: 16),
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
|
||||
|
||||
// 이 버튼이 QR 카메라를 켜는 버튼입니다.
|
||||
FilledButton.icon(
|
||||
onPressed: () {
|
||||
@@ -38,12 +41,17 @@ class LoginSuccessScreen extends StatelessWidget {
|
||||
},
|
||||
icon: const Icon(Icons.camera_alt, size: 28),
|
||||
label: Text(
|
||||
tr('ui.userfront.login_success.qr', fallback: 'QR 인증 (카메라 켜기)'),
|
||||
tr(
|
||||
'ui.userfront.login_success.qr',
|
||||
),
|
||||
),
|
||||
style: FilledButton.styleFrom(
|
||||
minimumSize: const Size.fromHeight(80), // 버튼 높이를 더 크게
|
||||
backgroundColor: Colors.blue.shade700,
|
||||
textStyle: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
@@ -57,7 +65,6 @@ class LoginSuccessScreen extends StatelessWidget {
|
||||
child: Text(
|
||||
tr(
|
||||
'ui.userfront.login_success.later',
|
||||
fallback: '나중에 하기 (대시보드로 이동)',
|
||||
),
|
||||
style: const TextStyle(color: Colors.grey),
|
||||
),
|
||||
|
||||
@@ -87,7 +87,7 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
|
||||
Future<void> _onDetect(BarcodeCapture capture) async {
|
||||
if (_isScanned) return;
|
||||
|
||||
|
||||
final List<Barcode> barcodes = capture.barcodes;
|
||||
for (final barcode in barcodes) {
|
||||
if (barcode.rawValue != null) {
|
||||
@@ -119,7 +119,7 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
|
||||
_log.info('QR Code detected raw: $qrData, ref: $pendingRef');
|
||||
final approveRef = qrData;
|
||||
|
||||
|
||||
final storedToken = AuthTokenStore.getToken();
|
||||
final sessionToken = storedToken;
|
||||
var usesCookie = AuthTokenStore.usesCookie();
|
||||
@@ -140,13 +140,12 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
token: sessionToken,
|
||||
withCredentials: usesCookie,
|
||||
);
|
||||
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isSuccess = true;
|
||||
_resultMessage = tr(
|
||||
'msg.userfront.qr.approve_success',
|
||||
fallback: 'QR 승인 완료! PC 화면에서 로그인이 진행됩니다.',
|
||||
);
|
||||
_isProcessing = false;
|
||||
});
|
||||
@@ -158,7 +157,6 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
_isSuccess = false;
|
||||
_resultMessage = tr(
|
||||
'msg.userfront.qr.approve_error',
|
||||
fallback: 'QR 승인 실패: {{error}}',
|
||||
params: {'error': '$e'},
|
||||
);
|
||||
_isProcessing = false;
|
||||
@@ -193,7 +191,6 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.qr.permission_error',
|
||||
fallback: '카메라 권한 요청에 실패했습니다. 브라우저/OS 설정을 확인해주세요.',
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.red,
|
||||
@@ -212,8 +209,8 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
final icon = success ? Icons.check_circle_outline : Icons.error_outline;
|
||||
final color = success ? Colors.green : Colors.red;
|
||||
final title = success
|
||||
? tr('ui.userfront.qr.result_success', fallback: '승인 완료')
|
||||
: tr('ui.userfront.qr.result_failure', fallback: '승인 실패');
|
||||
? tr('ui.userfront.qr.result_success')
|
||||
: tr('ui.userfront.qr.result_failure');
|
||||
final message = _resultMessage ?? '';
|
||||
|
||||
return Center(
|
||||
@@ -226,7 +223,11 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: color),
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
@@ -238,12 +239,12 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
if (!success)
|
||||
FilledButton(
|
||||
onPressed: _resetScan,
|
||||
child: Text(tr('ui.userfront.qr.rescan', fallback: '다시 스캔')),
|
||||
child: Text(tr('ui.userfront.qr.rescan')),
|
||||
),
|
||||
if (success)
|
||||
FilledButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(tr('ui.common.close', fallback: '닫기')),
|
||||
child: Text(tr('ui.common.close')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -268,7 +269,8 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
controller: controller,
|
||||
onDetect: _onDetect,
|
||||
errorBuilder: (context, error) {
|
||||
final isPermissionDenied = error.errorCode ==
|
||||
final isPermissionDenied =
|
||||
error.errorCode ==
|
||||
MobileScannerErrorCode.permissionDenied;
|
||||
return Center(
|
||||
child: Column(
|
||||
@@ -280,11 +282,9 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
isPermissionDenied
|
||||
? tr(
|
||||
'msg.userfront.qr.permission_required',
|
||||
fallback: '카메라 권한이 필요합니다.',
|
||||
)
|
||||
: tr(
|
||||
'msg.userfront.qr.camera_error',
|
||||
fallback: '카메라 오류: {{error}}',
|
||||
params: {'error': '${error.errorCode}'},
|
||||
),
|
||||
),
|
||||
@@ -295,10 +295,11 @@ class _QRScanScreenState extends State<QRScanScreen> {
|
||||
: _requestCameraPermission,
|
||||
child: Text(
|
||||
_isRequestingCamera
|
||||
? tr('ui.common.requesting', fallback: '요청 중...')
|
||||
? tr(
|
||||
'ui.common.requesting',
|
||||
)
|
||||
: tr(
|
||||
'ui.userfront.qr.request_permission',
|
||||
fallback: '카메라 권한 요청하기',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -13,7 +13,8 @@ class ResetPasswordScreen extends StatefulWidget {
|
||||
|
||||
class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
final TextEditingController _passwordController = TextEditingController();
|
||||
final TextEditingController _confirmPasswordController = TextEditingController();
|
||||
final TextEditingController _confirmPasswordController =
|
||||
TextEditingController();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
bool _isLoading = false;
|
||||
String? _loginId;
|
||||
@@ -31,13 +32,13 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
|
||||
// 2. Fallback to URI query parameter if not available via router
|
||||
if (_loginId == null || _loginId!.isEmpty) {
|
||||
final uri = Uri.base;
|
||||
_loginId = uri.queryParameters['loginId'];
|
||||
}
|
||||
final uri = Uri.base;
|
||||
_loginId = uri.queryParameters['loginId'];
|
||||
}
|
||||
|
||||
// 토큰도 함께 읽어놓는다.
|
||||
final uri = Uri.base;
|
||||
_token = uri.queryParameters['token'];
|
||||
// 토큰도 함께 읽어놓는다.
|
||||
final uri = Uri.base;
|
||||
_token = uri.queryParameters['token'];
|
||||
|
||||
_loadPolicy();
|
||||
}
|
||||
@@ -66,11 +67,11 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
|
||||
Future<void> _handlePasswordReset() async {
|
||||
if (_formKey.currentState?.validate() != true) return;
|
||||
if ((_loginId == null || _loginId!.isEmpty) && (_token == null || _token!.isEmpty)) {
|
||||
if ((_loginId == null || _loginId!.isEmpty) &&
|
||||
(_token == null || _token!.isEmpty)) {
|
||||
_showError(
|
||||
tr(
|
||||
'msg.userfront.reset.invalid_link',
|
||||
fallback: '유효하지 않은 재설정 링크입니다. (loginId/token 누락)',
|
||||
),
|
||||
);
|
||||
return;
|
||||
@@ -91,7 +92,6 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.reset.success',
|
||||
fallback: '비밀번호가 성공적으로 변경되었습니다. 다시 로그인해주세요.',
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.green,
|
||||
@@ -104,7 +104,6 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
_showError(
|
||||
tr(
|
||||
'msg.userfront.reset.error.generic',
|
||||
fallback: '비밀번호 변경에 실패했습니다: {{error}}',
|
||||
params: {'error': e.toString()},
|
||||
),
|
||||
);
|
||||
@@ -126,7 +125,6 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
if (_isPolicyLoading) {
|
||||
return tr(
|
||||
'msg.userfront.reset.policy_loading',
|
||||
fallback: '비밀번호 정책을 불러오는 중입니다...',
|
||||
);
|
||||
}
|
||||
final minLength = (_policy?['minLength'] as int?) ?? 12;
|
||||
@@ -139,7 +137,6 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
final parts = <String>[
|
||||
tr(
|
||||
'msg.userfront.reset.policy.min_length',
|
||||
fallback: '최소 {{count}}자 이상',
|
||||
params: {'count': '$minLength'},
|
||||
),
|
||||
];
|
||||
@@ -147,29 +144,26 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
parts.add(
|
||||
tr(
|
||||
'msg.userfront.reset.policy.min_types',
|
||||
fallback: '영문 대/소문자/숫자/특수문자 중 {{count}}가지 이상',
|
||||
params: {'count': '$minTypes'},
|
||||
),
|
||||
);
|
||||
}
|
||||
if (requiresLower) {
|
||||
parts.add(
|
||||
tr('msg.userfront.reset.policy.lowercase', fallback: '소문자 1개 이상'),
|
||||
tr('msg.userfront.reset.policy.lowercase'),
|
||||
);
|
||||
}
|
||||
if (requiresUpper) {
|
||||
parts.add(
|
||||
tr('msg.userfront.reset.policy.uppercase', fallback: '대문자 1개 이상'),
|
||||
tr('msg.userfront.reset.policy.uppercase'),
|
||||
);
|
||||
}
|
||||
if (requiresNumber) {
|
||||
parts.add(
|
||||
tr('msg.userfront.reset.policy.number', fallback: '숫자 1개 이상'),
|
||||
);
|
||||
parts.add(tr('msg.userfront.reset.policy.number'));
|
||||
}
|
||||
if (requiresSymbol) {
|
||||
parts.add(
|
||||
tr('msg.userfront.reset.policy.symbol', fallback: '특수문자 1개 이상'),
|
||||
tr('msg.userfront.reset.policy.symbol'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -180,16 +174,16 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
tr('ui.userfront.reset.title', fallback: '새 비밀번호 설정'),
|
||||
),
|
||||
title: Text(tr('ui.userfront.reset.title')),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Center(
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(maxWidth: 400),
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: (_loginId == null || _loginId!.isEmpty) && (_token == null || _token!.isEmpty)
|
||||
child:
|
||||
(_loginId == null || _loginId!.isEmpty) &&
|
||||
(_token == null || _token!.isEmpty)
|
||||
? _buildInvalidTokenView()
|
||||
: Form(
|
||||
key: _formKey,
|
||||
@@ -200,7 +194,6 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
Text(
|
||||
tr(
|
||||
'ui.userfront.reset.subtitle',
|
||||
fallback: '새로운 비밀번호 설정',
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
@@ -221,13 +214,14 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.reset.new_password',
|
||||
fallback: '새 비밀번호',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.lock_outline),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_isPasswordObscured ? Icons.visibility_off : Icons.visibility,
|
||||
_isPasswordObscured
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
@@ -241,14 +235,13 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
if (val.isEmpty) {
|
||||
return tr(
|
||||
'msg.userfront.reset.error.empty_password',
|
||||
fallback: '비밀번호를 입력해주세요.',
|
||||
);
|
||||
}
|
||||
final minLength = (_policy?['minLength'] as int?) ?? 12;
|
||||
final minLength =
|
||||
(_policy?['minLength'] as int?) ?? 12;
|
||||
if (val.length < minLength) {
|
||||
return tr(
|
||||
'msg.userfront.reset.error.min_length',
|
||||
fallback: '비밀번호는 최소 {{count}}자 이상이어야 합니다.',
|
||||
params: {'count': '$minLength'},
|
||||
);
|
||||
}
|
||||
@@ -262,12 +255,11 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
if (hasNumber) typeCount++;
|
||||
if (hasSymbol) typeCount++;
|
||||
|
||||
final minTypes = (_policy?['minCharacterTypes'] as int?) ?? 0;
|
||||
final minTypes =
|
||||
(_policy?['minCharacterTypes'] as int?) ?? 0;
|
||||
if (minTypes > 0 && typeCount < minTypes) {
|
||||
return tr(
|
||||
'msg.userfront.reset.error.min_types',
|
||||
fallback:
|
||||
'비밀번호는 영문 대/소문자/숫자/특수문자 중 {{count}}가지 이상 포함해야 합니다.',
|
||||
params: {'count': '$minTypes'},
|
||||
);
|
||||
}
|
||||
@@ -275,25 +267,22 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
if ((_policy?['lowercase'] ?? true) && !hasLower) {
|
||||
return tr(
|
||||
'msg.userfront.reset.error.lowercase',
|
||||
fallback: '최소 1개 이상의 소문자를 포함해야 합니다.',
|
||||
);
|
||||
}
|
||||
if ((_policy?['uppercase'] ?? false) && !hasUpper) {
|
||||
return tr(
|
||||
'msg.userfront.reset.error.uppercase',
|
||||
fallback: '최소 1개 이상의 대문자를 포함해야 합니다.',
|
||||
);
|
||||
}
|
||||
if ((_policy?['number'] ?? true) && !hasNumber) {
|
||||
return tr(
|
||||
'msg.userfront.reset.error.number',
|
||||
fallback: '최소 1개 이상의 숫자를 포함해야 합니다.',
|
||||
);
|
||||
}
|
||||
if ((_policy?['nonAlphanumeric'] ?? true) && !hasSymbol) {
|
||||
if ((_policy?['nonAlphanumeric'] ?? true) &&
|
||||
!hasSymbol) {
|
||||
return tr(
|
||||
'msg.userfront.reset.error.symbol',
|
||||
fallback: '최소 1개 이상의 특수문자를 포함해야 합니다.',
|
||||
);
|
||||
}
|
||||
return null;
|
||||
@@ -306,17 +295,19 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.reset.confirm_password',
|
||||
fallback: '새 비밀번호 확인',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
prefixIcon: const Icon(Icons.lock_outline),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_isConfirmPasswordObscured ? Icons.visibility_off : Icons.visibility,
|
||||
_isConfirmPasswordObscured
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isConfirmPasswordObscured = !_isConfirmPasswordObscured;
|
||||
_isConfirmPasswordObscured =
|
||||
!_isConfirmPasswordObscured;
|
||||
});
|
||||
},
|
||||
),
|
||||
@@ -325,7 +316,6 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
if (value != _passwordController.text) {
|
||||
return tr(
|
||||
'msg.userfront.reset.error.mismatch',
|
||||
fallback: '비밀번호가 일치하지 않습니다.',
|
||||
);
|
||||
}
|
||||
return null;
|
||||
@@ -349,7 +339,6 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
: Text(
|
||||
tr(
|
||||
'ui.userfront.reset.submit',
|
||||
fallback: '비밀번호 변경',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -369,8 +358,7 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
const Icon(Icons.error_outline, color: Colors.red, size: 60),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
tr('msg.userfront.reset.invalid_title',
|
||||
fallback: '유효하지 않은 링크입니다.'),
|
||||
tr('msg.userfront.reset.invalid_title'),
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@@ -378,7 +366,6 @@ class _ResetPasswordScreenState extends State<ResetPasswordScreen> {
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.reset.invalid_body',
|
||||
fallback: '비밀번호 재설정 링크가 만료되었거나 잘못되었습니다. 다시 시도해주세요.',
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
||||
@@ -164,30 +164,36 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
final email = _emailController.text.trim();
|
||||
final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
|
||||
if (!emailRegex.hasMatch(email)) {
|
||||
setState(() => _emailError = tr(
|
||||
'msg.userfront.signup.email.invalid',
|
||||
fallback: '유효한 이메일 형식이 아닙니다.',
|
||||
));
|
||||
setState(
|
||||
() => _emailError = tr(
|
||||
'msg.userfront.signup.email.invalid',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
setState(() { _isLoading = true; _emailError = null; });
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
_emailError = null;
|
||||
});
|
||||
try {
|
||||
final available = await AuthProxyService.checkEmailAvailability(email);
|
||||
if (!available) {
|
||||
setState(() => _emailError = tr(
|
||||
'msg.userfront.signup.email.duplicate',
|
||||
fallback: '이미 가입된 이메일입니다.',
|
||||
));
|
||||
setState(
|
||||
() => _emailError = tr(
|
||||
'msg.userfront.signup.email.duplicate',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
await AuthProxyService.sendSignupCode(email, 'email');
|
||||
_startTimer('email');
|
||||
} catch (e) {
|
||||
setState(() => _emailError = tr(
|
||||
'msg.userfront.signup.email.send_failed',
|
||||
fallback: '발송 실패: {{error}}',
|
||||
params: {'error': e.toString()},
|
||||
));
|
||||
setState(
|
||||
() => _emailError = tr(
|
||||
'msg.userfront.signup.email.send_failed',
|
||||
params: {'error': e.toString()},
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
@@ -197,7 +203,11 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
final code = _emailCodeController.text.trim();
|
||||
if (code.length != 6) return;
|
||||
try {
|
||||
final success = await AuthProxyService.verifySignupCode(_emailController.text.trim(), 'email', code);
|
||||
final success = await AuthProxyService.verifySignupCode(
|
||||
_emailController.text.trim(),
|
||||
'email',
|
||||
code,
|
||||
);
|
||||
if (success) {
|
||||
setState(() {
|
||||
_isEmailVerified = true;
|
||||
@@ -206,33 +216,39 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
_emailError = null;
|
||||
});
|
||||
} else {
|
||||
setState(() => _emailError = tr(
|
||||
'msg.userfront.signup.email.code_mismatch',
|
||||
fallback: '인증코드가 일치하지 않습니다.',
|
||||
));
|
||||
setState(
|
||||
() => _emailError = tr(
|
||||
'msg.userfront.signup.email.code_mismatch',
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() => _emailError = tr(
|
||||
'msg.userfront.signup.email.verify_failed',
|
||||
fallback: '인증 실패: {{error}}',
|
||||
params: {'error': e.toString()},
|
||||
));
|
||||
setState(
|
||||
() => _emailError = tr(
|
||||
'msg.userfront.signup.email.verify_failed',
|
||||
params: {'error': e.toString()},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _sendPhoneCode() async {
|
||||
final phone = _phoneController.text.trim();
|
||||
if (phone.isEmpty) return;
|
||||
setState(() { _isLoading = true; _phoneError = null; });
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
_phoneError = null;
|
||||
});
|
||||
try {
|
||||
await AuthProxyService.sendSignupCode(phone, 'phone');
|
||||
_startTimer('phone');
|
||||
} catch (e) {
|
||||
setState(() => _phoneError = tr(
|
||||
'msg.userfront.signup.phone.send_failed',
|
||||
fallback: '발송 실패: {{error}}',
|
||||
params: {'error': e.toString()},
|
||||
));
|
||||
setState(
|
||||
() => _phoneError = tr(
|
||||
'msg.userfront.signup.phone.send_failed',
|
||||
params: {'error': e.toString()},
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
@@ -242,7 +258,11 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
final code = _phoneCodeController.text.trim();
|
||||
if (code.length != 6) return;
|
||||
try {
|
||||
final success = await AuthProxyService.verifySignupCode(_phoneController.text.trim(), 'phone', code);
|
||||
final success = await AuthProxyService.verifySignupCode(
|
||||
_phoneController.text.trim(),
|
||||
'phone',
|
||||
code,
|
||||
);
|
||||
if (success) {
|
||||
setState(() {
|
||||
_isPhoneVerified = true;
|
||||
@@ -251,26 +271,29 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
_phoneError = null;
|
||||
});
|
||||
} else {
|
||||
setState(() => _phoneError = tr(
|
||||
'msg.userfront.signup.phone.code_mismatch',
|
||||
fallback: '인증코드가 일치하지 않습니다.',
|
||||
));
|
||||
setState(
|
||||
() => _phoneError = tr(
|
||||
'msg.userfront.signup.phone.code_mismatch',
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() => _phoneError = tr(
|
||||
'msg.userfront.signup.phone.verify_failed',
|
||||
fallback: '인증 실패: {{error}}',
|
||||
params: {'error': e.toString()},
|
||||
));
|
||||
setState(
|
||||
() => _phoneError = tr(
|
||||
'msg.userfront.signup.phone.verify_failed',
|
||||
params: {'error': e.toString()},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleSignup() async {
|
||||
if (_passwordController.text != _confirmPasswordController.text) {
|
||||
setState(() => _confirmPasswordError = tr(
|
||||
'msg.userfront.signup.password.mismatch',
|
||||
fallback: '비밀번호가 일치하지 않습니다.',
|
||||
));
|
||||
setState(
|
||||
() => _confirmPasswordError = tr(
|
||||
'msg.userfront.signup.password.mismatch',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
@@ -288,7 +311,9 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
phone: _phoneController.text.trim(),
|
||||
affiliationType: _affiliationType,
|
||||
companyCode: _affiliationType == 'AFFILIATE' ? _companyCode : null,
|
||||
department: _deptController.text.trim().isEmpty ? (_affiliationType == 'GENERAL' ? 'External' : '') : _deptController.text.trim(),
|
||||
department: _deptController.text.trim().isEmpty
|
||||
? (_affiliationType == 'GENERAL' ? 'External' : '')
|
||||
: _deptController.text.trim(),
|
||||
termsAccepted: true,
|
||||
);
|
||||
if (mounted) _showSuccessDialog();
|
||||
@@ -298,32 +323,26 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
if (eStr.contains('uppercase')) {
|
||||
_passwordError = tr(
|
||||
'msg.userfront.signup.password.uppercase_required',
|
||||
fallback: '대문자가 최소 1개 이상 포함되어야 합니다.',
|
||||
);
|
||||
} else if (eStr.contains('lowercase')) {
|
||||
_passwordError = tr(
|
||||
'msg.userfront.signup.password.lowercase_required',
|
||||
fallback: '소문자가 최소 1개 이상 포함되어야 합니다.',
|
||||
);
|
||||
} else if (eStr.contains('digit') || eStr.contains('number')) {
|
||||
_passwordError = tr(
|
||||
'msg.userfront.signup.password.number_required',
|
||||
fallback: '숫자가 최소 1개 이상 포함되어야 합니다.',
|
||||
);
|
||||
} else if (eStr.contains('symbol') || eStr.contains('special')) {
|
||||
_passwordError = tr(
|
||||
'msg.userfront.signup.password.symbol_required',
|
||||
fallback: '특수문자가 최소 1개 이상 포함되어야 합니다.',
|
||||
);
|
||||
} else if (eStr.contains('length') || eStr.contains('12 characters')) {
|
||||
_passwordError = tr(
|
||||
'msg.userfront.signup.password.length_required',
|
||||
fallback: '비밀번호는 최소 12자 이상이어야 합니다.',
|
||||
);
|
||||
} else {
|
||||
_passwordError = tr(
|
||||
'msg.userfront.signup.failed',
|
||||
fallback: '가입 실패: {{error}}',
|
||||
params: {'error': e.toString()},
|
||||
);
|
||||
}
|
||||
@@ -339,16 +358,16 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text(
|
||||
tr('msg.userfront.signup.success.title', fallback: '회원가입 완료'),
|
||||
tr('msg.userfront.signup.success.title'),
|
||||
),
|
||||
content: Text(
|
||||
tr('msg.userfront.signup.success.body', fallback: '성공적으로 가입되었습니다.'),
|
||||
tr('msg.userfront.signup.success.body'),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.go('/signin'),
|
||||
child: Text(
|
||||
tr('ui.userfront.signup.success.action', fallback: '로그인하기'),
|
||||
tr('ui.userfront.signup.success.action'),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -365,22 +384,22 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
children: [
|
||||
_stepCircle(
|
||||
1,
|
||||
tr('ui.userfront.signup.steps.agreement', fallback: '약관동의'),
|
||||
tr('ui.userfront.signup.steps.agreement'),
|
||||
),
|
||||
_stepLine(1),
|
||||
_stepCircle(
|
||||
2,
|
||||
tr('ui.userfront.signup.steps.verify', fallback: '본인인증'),
|
||||
tr('ui.userfront.signup.steps.verify'),
|
||||
),
|
||||
_stepLine(2),
|
||||
_stepCircle(
|
||||
3,
|
||||
tr('ui.userfront.signup.steps.profile', fallback: '정보입력'),
|
||||
tr('ui.userfront.signup.steps.profile'),
|
||||
),
|
||||
_stepLine(3),
|
||||
_stepCircle(
|
||||
4,
|
||||
tr('ui.userfront.signup.steps.password', fallback: '비밀번호'),
|
||||
tr('ui.userfront.signup.steps.password'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -394,11 +413,28 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 12,
|
||||
backgroundColor: isDone ? Colors.green : (isCurrent ? Colors.black : Colors.grey[300]),
|
||||
child: isDone ? const Icon(Icons.check, size: 14, color: Colors.white) : Text('$step', style: TextStyle(color: isCurrent ? Colors.white : Colors.black54, fontSize: 10)),
|
||||
backgroundColor: isDone
|
||||
? Colors.green
|
||||
: (isCurrent ? Colors.black : Colors.grey[300]),
|
||||
child: isDone
|
||||
? const Icon(Icons.check, size: 14, color: Colors.white)
|
||||
: Text(
|
||||
'$step',
|
||||
style: TextStyle(
|
||||
color: isCurrent ? Colors.white : Colors.black54,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(label, style: TextStyle(fontSize: 9, color: isCurrent ? Colors.black : Colors.grey, fontWeight: isCurrent ? FontWeight.bold : FontWeight.normal)),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
color: isCurrent ? Colors.black : Colors.grey,
|
||||
fontWeight: isCurrent ? FontWeight.bold : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -420,7 +456,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.signup.agreement.title',
|
||||
fallback: '서비스 이용을 위해\n약관에 동의해주세요',
|
||||
),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
@@ -438,10 +473,7 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
),
|
||||
child: CheckboxListTile(
|
||||
title: Text(
|
||||
tr(
|
||||
'ui.userfront.signup.agreement.all',
|
||||
fallback: '모두 동의합니다',
|
||||
),
|
||||
tr('ui.userfront.signup.agreement.all'),
|
||||
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
|
||||
),
|
||||
value: _termsAccepted && _privacyAccepted,
|
||||
@@ -459,7 +491,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
_agreementSection(
|
||||
title: tr(
|
||||
'ui.userfront.signup.agreement.tos_title',
|
||||
fallback: '바론 소프트웨어 이용약관 (필수)',
|
||||
),
|
||||
content: _tosText,
|
||||
value: _termsAccepted,
|
||||
@@ -469,7 +500,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
_agreementSection(
|
||||
title: tr(
|
||||
'ui.userfront.signup.agreement.privacy_title',
|
||||
fallback: '개인정보 수집 및 이용 동의 (필수)',
|
||||
),
|
||||
content: _privacyText,
|
||||
value: _privacyAccepted,
|
||||
@@ -488,8 +518,10 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
return Column(
|
||||
children: [
|
||||
CheckboxListTile(
|
||||
title: Text(title,
|
||||
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),
|
||||
title: Text(
|
||||
title,
|
||||
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
|
||||
),
|
||||
value: value,
|
||||
onChanged: onChanged,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
@@ -508,7 +540,11 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
child: SingleChildScrollView(
|
||||
child: Text(
|
||||
content,
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey, height: 1.5),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -517,8 +553,8 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
}
|
||||
|
||||
static String get _tosText => tr(
|
||||
'msg.userfront.signup.tos_full',
|
||||
fallback: """
|
||||
'msg.userfront.signup.tos_full',
|
||||
fallback: """
|
||||
바론 소프트웨어 이용약관
|
||||
|
||||
제1장 총칙
|
||||
@@ -589,11 +625,11 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
부칙
|
||||
본 약관은 2024년 10월 1일부터 시행됩니다.
|
||||
""",
|
||||
);
|
||||
);
|
||||
|
||||
static String get _privacyText => tr(
|
||||
'msg.userfront.signup.privacy_full',
|
||||
fallback: """
|
||||
'msg.userfront.signup.privacy_full',
|
||||
fallback: """
|
||||
개인정보 수집 및 이용 동의
|
||||
|
||||
바론서비스 개인정보처리방침
|
||||
@@ -702,7 +738,7 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
제8조 (기타)
|
||||
본 방침에 명시되지 않은 사항은 회사의 내부 방침과 관련 법령에 따릅니다.
|
||||
""",
|
||||
);
|
||||
);
|
||||
|
||||
Widget _buildStepAuth() {
|
||||
return Column(
|
||||
@@ -711,7 +747,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.signup.auth.title',
|
||||
fallback: '본인 확인을 위해\n인증을 진행해주세요',
|
||||
),
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
@@ -719,7 +754,10 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
// 가족사 이메일 안내 문구
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: BoxDecoration(color: Colors.blue[50], borderRadius: BorderRadius.circular(6)),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue[50],
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.info_outline, size: 16, color: Colors.blue),
|
||||
@@ -728,9 +766,12 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
child: Text(
|
||||
tr(
|
||||
'msg.userfront.signup.auth.affiliate_notice',
|
||||
fallback: '가족사 회원의 경우 반드시 회사 공식 이메일을 입력해주세요.',
|
||||
),
|
||||
style: const TextStyle(fontSize: 12, color: Colors.blue, fontWeight: FontWeight.w500),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.blue,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -738,7 +779,7 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
tr('ui.userfront.signup.auth.email.title', fallback: '이메일 인증'),
|
||||
tr('ui.userfront.signup.auth.email.title'),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -751,9 +792,8 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.signup.auth.email.label',
|
||||
fallback: '이메일 주소',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
border: const OutlineInputBorder(),
|
||||
errorText: _emailError,
|
||||
hintText: 'example@hanmaceng.co.kr',
|
||||
),
|
||||
@@ -764,14 +804,19 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
SizedBox(
|
||||
height: 55,
|
||||
child: ElevatedButton(
|
||||
onPressed: (_isEmailVerified || _isLoading) ? null : _sendEmailCode,
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.grey[100], foregroundColor: Colors.black, elevation: 0),
|
||||
onPressed: (_isEmailVerified || _isLoading)
|
||||
? null
|
||||
: _sendEmailCode,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.grey[100],
|
||||
foregroundColor: Colors.black,
|
||||
elevation: 0,
|
||||
),
|
||||
child: Text(
|
||||
_emailSeconds > 0
|
||||
? tr('ui.common.resend', fallback: '재발송')
|
||||
? tr('ui.common.resend')
|
||||
: tr(
|
||||
'ui.userfront.signup.auth.request_code',
|
||||
fallback: '인증요청',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -785,14 +830,18 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.signup.auth.code_label',
|
||||
fallback: '인증코드 6자리',
|
||||
),
|
||||
suffixText: _formatTime(_emailSeconds),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly, LengthLimitingTextInputFormatter(6)],
|
||||
onChanged: (val) { if(val.length == 6) _verifyEmailCode(); },
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
LengthLimitingTextInputFormatter(6),
|
||||
],
|
||||
onChanged: (val) {
|
||||
if (val.length == 6) _verifyEmailCode();
|
||||
},
|
||||
),
|
||||
],
|
||||
if (_isEmailVerified)
|
||||
@@ -801,7 +850,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
child: Text(
|
||||
tr(
|
||||
'msg.userfront.signup.email.verified',
|
||||
fallback: '✅ 이메일 인증 완료',
|
||||
),
|
||||
style: const TextStyle(
|
||||
color: Colors.green,
|
||||
@@ -812,7 +860,7 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
tr('ui.userfront.signup.phone.title', fallback: '휴대폰 인증'),
|
||||
tr('ui.userfront.signup.phone.title'),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -824,7 +872,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.signup.phone.label',
|
||||
fallback: '휴대폰 번호 (-없이)',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
errorText: _phoneError,
|
||||
@@ -837,14 +884,19 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
SizedBox(
|
||||
height: 55,
|
||||
child: ElevatedButton(
|
||||
onPressed: (_isPhoneVerified || _isLoading) ? null : _sendPhoneCode,
|
||||
style: ElevatedButton.styleFrom(backgroundColor: Colors.grey[100], foregroundColor: Colors.black, elevation: 0),
|
||||
onPressed: (_isPhoneVerified || _isLoading)
|
||||
? null
|
||||
: _sendPhoneCode,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.grey[100],
|
||||
foregroundColor: Colors.black,
|
||||
elevation: 0,
|
||||
),
|
||||
child: Text(
|
||||
_phoneSeconds > 0
|
||||
? tr('ui.common.resend', fallback: '재발송')
|
||||
? tr('ui.common.resend')
|
||||
: tr(
|
||||
'ui.userfront.signup.auth.request_code',
|
||||
fallback: '인증요청',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -858,14 +910,18 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.signup.auth.code_label',
|
||||
fallback: '인증코드 6자리',
|
||||
),
|
||||
suffixText: _formatTime(_phoneSeconds),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly, LengthLimitingTextInputFormatter(6)],
|
||||
onChanged: (val) { if(val.length == 6) _verifyPhoneCode(); },
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
LengthLimitingTextInputFormatter(6),
|
||||
],
|
||||
onChanged: (val) {
|
||||
if (val.length == 6) _verifyPhoneCode();
|
||||
},
|
||||
),
|
||||
],
|
||||
if (_isPhoneVerified)
|
||||
@@ -874,7 +930,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
child: Text(
|
||||
tr(
|
||||
'msg.userfront.signup.phone.verified',
|
||||
fallback: '✅ 휴대폰 인증 완료',
|
||||
),
|
||||
style: const TextStyle(
|
||||
color: Colors.green,
|
||||
@@ -894,7 +949,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.signup.profile.title',
|
||||
fallback: '회원님의\n소속 정보를 알려주세요',
|
||||
),
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
@@ -903,10 +957,7 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
controller: _nameController,
|
||||
onChanged: (_) => setState(() {}),
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.signup.profile.name',
|
||||
fallback: '이름',
|
||||
),
|
||||
labelText: tr('ui.userfront.signup.profile.name'),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
@@ -922,13 +973,11 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.signup.profile.affiliation_type',
|
||||
fallback: '소속 유형',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
helperText: _isAffiliateEmail
|
||||
? tr(
|
||||
'msg.userfront.signup.profile.affiliate_hint',
|
||||
fallback: '가족사 이메일 사용 시 자동으로 선택됩니다.',
|
||||
)
|
||||
: null,
|
||||
),
|
||||
@@ -936,19 +985,13 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
DropdownMenuItem(
|
||||
value: 'GENERAL',
|
||||
child: Text(
|
||||
tr(
|
||||
'domain.affiliation.general',
|
||||
fallback: '일반 사용자',
|
||||
),
|
||||
tr('domain.affiliation.general'),
|
||||
),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'AFFILIATE',
|
||||
child: Text(
|
||||
tr(
|
||||
'domain.affiliation.affiliate',
|
||||
fallback: '가족사 임직원',
|
||||
),
|
||||
tr('domain.affiliation.affiliate'),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -978,46 +1021,33 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.signup.profile.company',
|
||||
fallback: '가족사 선택',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
value: 'HANMAC',
|
||||
child: Text(
|
||||
tr('domain.company.hanmac', fallback: '한맥'),
|
||||
),
|
||||
child: Text(tr('domain.company.hanmac')),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'SAMAN',
|
||||
child: Text(
|
||||
tr('domain.company.saman', fallback: '삼안'),
|
||||
),
|
||||
child: Text(tr('domain.company.saman')),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'PTC',
|
||||
child: Text(
|
||||
tr('domain.company.ptc', fallback: 'PTC'),
|
||||
),
|
||||
child: Text(tr('domain.company.ptc', fallback: 'PTC')),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'JANGHEON',
|
||||
child: Text(
|
||||
tr('domain.company.jangheon', fallback: '장헌'),
|
||||
),
|
||||
child: Text(tr('domain.company.jangheon')),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'BARON',
|
||||
child: Text(
|
||||
tr('domain.company.baron', fallback: '바론'),
|
||||
),
|
||||
child: Text(tr('domain.company.baron')),
|
||||
),
|
||||
DropdownMenuItem(
|
||||
value: 'HALLA',
|
||||
child: Text(
|
||||
tr('domain.company.halla', fallback: '한라'),
|
||||
),
|
||||
child: Text(tr('domain.company.halla')),
|
||||
),
|
||||
],
|
||||
onChanged: _isAffiliateEmail
|
||||
@@ -1033,12 +1063,11 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
onChanged: (_) => setState(() {}),
|
||||
decoration: InputDecoration(
|
||||
labelText: _affiliationType == 'AFFILIATE'
|
||||
? tr('ui.userfront.signup.profile.department', fallback: '부서명')
|
||||
? tr('ui.userfront.signup.profile.department')
|
||||
: tr(
|
||||
'ui.userfront.signup.profile.department_optional',
|
||||
fallback: '소속 정보 (선택)',
|
||||
),
|
||||
border: const OutlineInputBorder()
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -1049,7 +1078,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
if (_isPolicyLoading) {
|
||||
return tr(
|
||||
'msg.userfront.signup.policy.loading',
|
||||
fallback: '비밀번호 정책을 불러오는 중입니다...',
|
||||
);
|
||||
}
|
||||
final minLength = (_policy?['minLength'] as int?) ?? 12;
|
||||
@@ -1062,7 +1090,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
final parts = <String>[
|
||||
tr(
|
||||
'msg.userfront.signup.policy.min_length',
|
||||
fallback: '최소 {{count}}자 이상',
|
||||
params: {'count': minLength.toString()},
|
||||
),
|
||||
];
|
||||
@@ -1070,54 +1097,32 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
parts.add(
|
||||
tr(
|
||||
'msg.userfront.signup.policy.min_types',
|
||||
fallback: '영문 대/소문자/숫자/특수문자 중 {{count}}가지 이상',
|
||||
params: {'count': minTypes.toString()},
|
||||
),
|
||||
);
|
||||
}
|
||||
if (requiresUpper) {
|
||||
parts.add(
|
||||
tr(
|
||||
'msg.userfront.signup.policy.uppercase',
|
||||
fallback: '대문자',
|
||||
),
|
||||
);
|
||||
parts.add(tr('msg.userfront.signup.policy.uppercase'));
|
||||
}
|
||||
if (requiresLower) {
|
||||
parts.add(
|
||||
tr(
|
||||
'msg.userfront.signup.policy.lowercase',
|
||||
fallback: '소문자',
|
||||
),
|
||||
);
|
||||
parts.add(tr('msg.userfront.signup.policy.lowercase'));
|
||||
}
|
||||
if (requiresNumber) {
|
||||
parts.add(
|
||||
tr(
|
||||
'msg.userfront.signup.policy.number',
|
||||
fallback: '숫자',
|
||||
),
|
||||
);
|
||||
parts.add(tr('msg.userfront.signup.policy.number'));
|
||||
}
|
||||
if (requiresSymbol) {
|
||||
parts.add(
|
||||
tr(
|
||||
'msg.userfront.signup.policy.symbol',
|
||||
fallback: '특수문자',
|
||||
),
|
||||
);
|
||||
parts.add(tr('msg.userfront.signup.policy.symbol'));
|
||||
}
|
||||
|
||||
return tr(
|
||||
'msg.userfront.signup.policy.summary',
|
||||
fallback: '보안 정책: {{rules}}',
|
||||
params: {'rules': parts.join(', ')},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStepPassword() {
|
||||
String p = _passwordController.text;
|
||||
|
||||
|
||||
// Default Policy Fallback
|
||||
final minLength = (_policy?['minLength'] as int?) ?? 12;
|
||||
final minTypes = (_policy?['minCharacterTypes'] as int?) ?? 0;
|
||||
@@ -1144,7 +1149,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.signup.password.title',
|
||||
fallback: '마지막으로\n비밀번호를 설정해주세요',
|
||||
),
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
@@ -1152,7 +1156,10 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
// 비밀번호 정책 안내 박스
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(color: Colors.blue[50], borderRadius: BorderRadius.circular(8)),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue[50],
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.security, size: 18, color: Colors.blue),
|
||||
@@ -1160,7 +1167,11 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
Expanded(
|
||||
child: Text(
|
||||
_buildPolicyDescription(),
|
||||
style: TextStyle(fontSize: 12, color: Colors.blue[800], fontWeight: FontWeight.w500),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.blue[800],
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -1174,7 +1185,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.signup.password.label',
|
||||
fallback: '비밀번호',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
errorText: _passwordError,
|
||||
@@ -1187,7 +1197,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
_cryptoCheck(
|
||||
tr(
|
||||
'msg.userfront.signup.password.rule.min_length',
|
||||
fallback: '{{count}}자 이상',
|
||||
params: {'count': minLength.toString()},
|
||||
),
|
||||
hasLength,
|
||||
@@ -1196,7 +1205,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
_cryptoCheck(
|
||||
tr(
|
||||
'msg.userfront.signup.password.rule.min_types',
|
||||
fallback: '문자 유형 {{count}}가지 이상',
|
||||
params: {'count': minTypes.toString()},
|
||||
),
|
||||
hasTypeCount,
|
||||
@@ -1205,7 +1213,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
_cryptoCheck(
|
||||
tr(
|
||||
'msg.userfront.signup.password.rule.uppercase',
|
||||
fallback: '대문자',
|
||||
),
|
||||
hasUpper,
|
||||
),
|
||||
@@ -1213,23 +1220,18 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
_cryptoCheck(
|
||||
tr(
|
||||
'msg.userfront.signup.password.rule.lowercase',
|
||||
fallback: '소문자',
|
||||
),
|
||||
hasLower,
|
||||
),
|
||||
if (requiresNumber)
|
||||
_cryptoCheck(
|
||||
tr(
|
||||
'msg.userfront.signup.password.rule.number',
|
||||
fallback: '숫자',
|
||||
),
|
||||
tr('msg.userfront.signup.password.rule.number'),
|
||||
hasDigit,
|
||||
),
|
||||
if (requiresSymbol)
|
||||
_cryptoCheck(
|
||||
tr(
|
||||
'msg.userfront.signup.password.rule.symbol',
|
||||
fallback: '특수문자',
|
||||
),
|
||||
hasSpecial,
|
||||
),
|
||||
@@ -1244,7 +1246,6 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
_confirmPasswordError = (val != _passwordController.text)
|
||||
? tr(
|
||||
'msg.userfront.signup.password.mismatch',
|
||||
fallback: '비밀번호가 일치하지 않습니다.',
|
||||
)
|
||||
: null;
|
||||
});
|
||||
@@ -1252,8 +1253,7 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.signup.password.confirm_label',
|
||||
fallback: '비밀번호 확인',
|
||||
),
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
errorText: _confirmPasswordError,
|
||||
),
|
||||
@@ -1266,9 +1266,19 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(isValid ? Icons.check_circle : Icons.circle_outlined, size: 14, color: isValid ? Colors.green : Colors.grey),
|
||||
Icon(
|
||||
isValid ? Icons.check_circle : Icons.circle_outlined,
|
||||
size: 14,
|
||||
color: isValid ? Colors.green : Colors.grey,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(label, style: TextStyle(fontSize: 11, color: isValid ? Colors.green : Colors.grey)),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isValid ? Colors.green : Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -1276,8 +1286,10 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool canGoNext = false;
|
||||
if (_currentStep == 1 && _termsAccepted && _privacyAccepted) canGoNext = true;
|
||||
if (_currentStep == 2 && _isEmailVerified && _isPhoneVerified) canGoNext = true;
|
||||
if (_currentStep == 1 && _termsAccepted && _privacyAccepted)
|
||||
canGoNext = true;
|
||||
if (_currentStep == 2 && _isEmailVerified && _isPhoneVerified)
|
||||
canGoNext = true;
|
||||
if (_currentStep == 3) {
|
||||
final nameOk = _nameController.text.trim().isNotEmpty;
|
||||
if (_affiliationType == 'GENERAL') {
|
||||
@@ -1294,7 +1306,7 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
tr('ui.userfront.signup.title', fallback: '회원가입'),
|
||||
tr('ui.userfront.signup.title'),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
elevation: 0,
|
||||
@@ -1313,11 +1325,13 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: _currentStep == 1
|
||||
? _buildStepAgreement()
|
||||
: (_currentStep == 2
|
||||
? _buildStepAuth()
|
||||
: (_currentStep == 3 ? _buildStepInfo() : _buildStepPassword())),
|
||||
child: _currentStep == 1
|
||||
? _buildStepAgreement()
|
||||
: (_currentStep == 2
|
||||
? _buildStepAuth()
|
||||
: (_currentStep == 3
|
||||
? _buildStepInfo()
|
||||
: _buildStepPassword())),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1329,9 +1343,12 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: () => setState(() => _currentStep--),
|
||||
style: OutlinedButton.styleFrom(minimumSize: const Size.fromHeight(55), side: const BorderSide(color: Colors.black)),
|
||||
style: OutlinedButton.styleFrom(
|
||||
minimumSize: const Size.fromHeight(55),
|
||||
side: const BorderSide(color: Colors.black),
|
||||
),
|
||||
child: Text(
|
||||
tr('ui.common.prev', fallback: '이전'),
|
||||
tr('ui.common.prev'),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
),
|
||||
),
|
||||
@@ -1340,20 +1357,33 @@ class _SignupScreenState extends State<SignupScreen> {
|
||||
],
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: _currentStep < 4
|
||||
? (canGoNext ? () => setState(() => _currentStep++) : null)
|
||||
: (_isLoading ? null : _handleSignup),
|
||||
onPressed: _currentStep < 4
|
||||
? (canGoNext
|
||||
? () => setState(() => _currentStep++)
|
||||
: null)
|
||||
: (_isLoading ? null : _handleSignup),
|
||||
style: FilledButton.styleFrom(
|
||||
minimumSize: const Size.fromHeight(55),
|
||||
backgroundColor: Colors.black,
|
||||
),
|
||||
child: _isLoading
|
||||
? const SizedBox(height: 20, width: 20, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
||||
: Text(
|
||||
_currentStep < 4
|
||||
? tr('ui.userfront.signup.next_step', fallback: '다음 단계')
|
||||
: tr('ui.userfront.signup.complete', fallback: '가입 완료'),
|
||||
),
|
||||
child: _isLoading
|
||||
? const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
_currentStep < 4
|
||||
? tr(
|
||||
'ui.userfront.signup.next_step',
|
||||
)
|
||||
: tr(
|
||||
'ui.userfront.signup.complete',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -181,7 +181,6 @@ class AuthTimelineNotifier extends Notifier<AuthTimelineState> {
|
||||
isLoadingMore: false,
|
||||
error: tr(
|
||||
'msg.userfront.dashboard.timeline.load_error',
|
||||
fallback: '접속이력을 불러오지 못했습니다.',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,7 +25,7 @@ class ProfileRepository {
|
||||
final useCookie = AuthTokenStore.usesCookie();
|
||||
if (token == null && !useCookie) {
|
||||
throw Exception(
|
||||
tr('err.userfront.session.missing', fallback: '활성 세션이 없습니다.'),
|
||||
tr('err.userfront.session.missing'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ class ProfileRepository {
|
||||
throw Exception(
|
||||
tr(
|
||||
'err.userfront.profile.load_failed',
|
||||
fallback: '프로필을 불러오지 못했습니다: {{error}}',
|
||||
params: {'error': response.body},
|
||||
),
|
||||
);
|
||||
@@ -62,7 +61,7 @@ class ProfileRepository {
|
||||
final useCookie = AuthTokenStore.usesCookie();
|
||||
if (token == null && !useCookie) {
|
||||
throw Exception(
|
||||
tr('err.userfront.session.missing', fallback: '활성 세션이 없습니다.'),
|
||||
tr('err.userfront.session.missing'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -89,7 +88,6 @@ class ProfileRepository {
|
||||
throw Exception(
|
||||
tr(
|
||||
'err.userfront.profile.update_failed',
|
||||
fallback: '프로필 업데이트에 실패했습니다: {{error}}',
|
||||
params: {'error': response.body},
|
||||
),
|
||||
);
|
||||
@@ -101,7 +99,7 @@ class ProfileRepository {
|
||||
final useCookie = AuthTokenStore.usesCookie();
|
||||
if (token == null && !useCookie) {
|
||||
throw Exception(
|
||||
tr('err.userfront.session.missing', fallback: '활성 세션이 없습니다.'),
|
||||
tr('err.userfront.session.missing'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,7 +122,6 @@ class ProfileRepository {
|
||||
throw Exception(
|
||||
tr(
|
||||
'err.userfront.profile.send_code_failed',
|
||||
fallback: '인증번호 전송 실패: {{error}}',
|
||||
params: {'error': response.body},
|
||||
),
|
||||
);
|
||||
@@ -139,7 +136,7 @@ class ProfileRepository {
|
||||
final useCookie = AuthTokenStore.usesCookie();
|
||||
if (token == null && !useCookie) {
|
||||
throw Exception(
|
||||
tr('err.userfront.session.missing', fallback: '활성 세션이 없습니다.'),
|
||||
tr('err.userfront.session.missing'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -165,7 +162,6 @@ class ProfileRepository {
|
||||
throw Exception(
|
||||
tr(
|
||||
'err.userfront.profile.password_change_failed',
|
||||
fallback: '비밀번호 변경에 실패했습니다: {{error}}',
|
||||
params: {'error': response.body},
|
||||
),
|
||||
);
|
||||
@@ -177,7 +173,7 @@ class ProfileRepository {
|
||||
final useCookie = AuthTokenStore.usesCookie();
|
||||
if (token == null && !useCookie) {
|
||||
throw Exception(
|
||||
tr('err.userfront.session.missing', fallback: '활성 세션이 없습니다.'),
|
||||
tr('err.userfront.session.missing'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -200,7 +196,6 @@ class ProfileRepository {
|
||||
throw Exception(
|
||||
tr(
|
||||
'err.userfront.profile.verify_code_failed',
|
||||
fallback: '인증 실패: {{error}}',
|
||||
params: {'error': response.body},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:userfront/i18n.dart';
|
||||
import '../../../../core/notifiers/auth_notifier.dart';
|
||||
import '../../../../core/services/auth_token_store.dart';
|
||||
import '../../../../core/ui/layout_breakpoints.dart';
|
||||
import '../../../../core/widgets/language_selector.dart';
|
||||
import '../../data/models/user_profile_model.dart';
|
||||
import '../../domain/notifiers/profile_notifier.dart';
|
||||
|
||||
@@ -140,7 +141,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
if (_editingField != 'name' && _nameController!.text != profile.name) {
|
||||
_nameController!.text = profile.name;
|
||||
}
|
||||
if (_editingField != 'department' && _departmentController!.text != profile.department) {
|
||||
if (_editingField != 'department' &&
|
||||
_departmentController!.text != profile.department) {
|
||||
_departmentController!.text = profile.department;
|
||||
}
|
||||
if (_editingField != 'phone' && _phoneController!.text != profile.phone) {
|
||||
@@ -234,7 +236,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.phone.code_sent',
|
||||
fallback: '인증번호가 전송되었습니다.',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -248,7 +249,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.phone.send_failed',
|
||||
fallback: '전송 실패: {{error}}',
|
||||
params: {'error': e.toString()},
|
||||
),
|
||||
),
|
||||
@@ -274,10 +274,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.phone.verified',
|
||||
fallback: '인증되었습니다.',
|
||||
),
|
||||
tr('msg.userfront.profile.phone.verified'),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -293,7 +290,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.phone.verify_failed',
|
||||
fallback: '인증 실패: {{error}}',
|
||||
params: {'error': e.toString()},
|
||||
),
|
||||
),
|
||||
@@ -310,24 +306,27 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
final confirmPassword = _confirmPasswordController?.text.trim() ?? '';
|
||||
|
||||
if (currentPassword.isEmpty) {
|
||||
setState(() => _passwordError = tr(
|
||||
'msg.userfront.profile.password.current_required',
|
||||
fallback: '현재 비밀번호를 입력해 주세요.',
|
||||
));
|
||||
setState(
|
||||
() => _passwordError = tr(
|
||||
'msg.userfront.profile.password.current_required',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (newPassword.isEmpty) {
|
||||
setState(() => _passwordError = tr(
|
||||
'msg.userfront.profile.password.new_required',
|
||||
fallback: '새 비밀번호를 입력해 주세요.',
|
||||
));
|
||||
setState(
|
||||
() => _passwordError = tr(
|
||||
'msg.userfront.profile.password.new_required',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (newPassword != confirmPassword) {
|
||||
setState(() => _passwordError = tr(
|
||||
'msg.userfront.profile.password.mismatch',
|
||||
fallback: '새 비밀번호가 일치하지 않습니다.',
|
||||
));
|
||||
setState(
|
||||
() => _passwordError = tr(
|
||||
'msg.userfront.profile.password.mismatch',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -338,7 +337,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
});
|
||||
|
||||
try {
|
||||
await ref.read(profileRepositoryProvider).changePassword(
|
||||
await ref
|
||||
.read(profileRepositoryProvider)
|
||||
.changePassword(
|
||||
currentPassword: currentPassword,
|
||||
newPassword: newPassword,
|
||||
);
|
||||
@@ -348,7 +349,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
setState(() {
|
||||
_passwordSuccess = tr(
|
||||
'msg.userfront.profile.password.changed',
|
||||
fallback: '비밀번호가 변경되었습니다.',
|
||||
);
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -356,7 +356,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
setState(() {
|
||||
_passwordError = tr(
|
||||
'msg.userfront.profile.password.change_failed',
|
||||
fallback: '비밀번호 변경 실패: {{error}}',
|
||||
params: {'error': message},
|
||||
);
|
||||
});
|
||||
@@ -434,10 +433,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.name_required',
|
||||
fallback: '이름을 입력해주세요.',
|
||||
),
|
||||
tr('msg.userfront.profile.name_required'),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -449,7 +445,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.department_required',
|
||||
fallback: '소속을 입력해주세요.',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -463,7 +458,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.phone_required',
|
||||
fallback: '휴대폰 번호를 입력해주세요.',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -476,7 +470,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.phone_verify_required',
|
||||
fallback: '휴대폰 번호 인증이 필요합니다.',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -500,7 +493,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
_isSavingField = true;
|
||||
|
||||
try {
|
||||
await ref.read(profileProvider.notifier).updateProfile(
|
||||
await ref
|
||||
.read(profileProvider.notifier)
|
||||
.updateProfile(
|
||||
name: nextName,
|
||||
phone: nextPhone,
|
||||
department: nextDepartment,
|
||||
@@ -520,7 +515,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.update_success',
|
||||
fallback: '정보가 수정되었습니다.',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -533,7 +527,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
content: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.update_failed',
|
||||
fallback: '수정 실패: {{error}}',
|
||||
params: {'error': e.toString()},
|
||||
),
|
||||
),
|
||||
@@ -546,38 +539,40 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
}
|
||||
|
||||
Widget _buildSideMenu(BuildContext context) {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.home_outlined),
|
||||
title: Text(
|
||||
tr('ui.userfront.nav.dashboard', fallback: '대시보드'),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.home_outlined),
|
||||
title: Text(tr('ui.userfront.nav.dashboard')),
|
||||
onTap: () => context.go('/'),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.person_outline),
|
||||
title: Text(tr('ui.userfront.nav.profile')),
|
||||
selected: true,
|
||||
onTap: () => context.go('/profile'),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.qr_code_scanner),
|
||||
title: Text(tr('ui.userfront.nav.qr_scan')),
|
||||
onTap: () => context.go('/scan'),
|
||||
),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.logout),
|
||||
title: Text(tr('ui.userfront.nav.logout')),
|
||||
onTap: _logout,
|
||||
),
|
||||
],
|
||||
),
|
||||
onTap: () => context.go('/'),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.person_outline),
|
||||
title: Text(
|
||||
tr('ui.userfront.nav.profile', fallback: '내 정보'),
|
||||
),
|
||||
selected: true,
|
||||
onTap: () => context.go('/profile'),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.qr_code_scanner),
|
||||
title: Text(
|
||||
tr('ui.userfront.nav.qr_scan', fallback: 'QR 스캔'),
|
||||
),
|
||||
onTap: () => context.go('/scan'),
|
||||
),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.logout),
|
||||
title: Text(
|
||||
tr('ui.userfront.nav.logout', fallback: '로그아웃'),
|
||||
),
|
||||
onTap: _logout,
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(bottom: 16),
|
||||
child: LanguageSelector(compact: true),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -589,13 +584,14 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w700, color: _ink),
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: _ink,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(fontSize: 13, color: Colors.grey[600]),
|
||||
),
|
||||
Text(subtitle, style: TextStyle(fontSize: 13, color: Colors.grey[600])),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -615,7 +611,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(fontSize: 12, color: _ink, fontWeight: FontWeight.w600),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: _ink,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -624,13 +624,13 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
|
||||
Widget _buildHeaderCard(UserProfile profile) {
|
||||
final name = profile.name.isEmpty
|
||||
? tr('msg.userfront.profile.name_missing', fallback: '이름 없음')
|
||||
? tr('msg.userfront.profile.name_missing')
|
||||
: profile.name;
|
||||
final email = profile.email.isEmpty
|
||||
? tr('msg.userfront.profile.email_missing', fallback: '이메일 없음')
|
||||
? tr('msg.userfront.profile.email_missing')
|
||||
: profile.email;
|
||||
final department = profile.department.isEmpty
|
||||
? tr('msg.userfront.profile.department_missing', fallback: '소속 정보 없음')
|
||||
? tr('msg.userfront.profile.department_missing')
|
||||
: profile.department;
|
||||
|
||||
return Container(
|
||||
@@ -650,10 +650,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const CircleAvatar(
|
||||
radius: 32,
|
||||
child: Icon(Icons.person, size: 32),
|
||||
),
|
||||
const CircleAvatar(radius: 32, child: Icon(Icons.person, size: 32)),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
@@ -662,7 +659,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.profile.greeting',
|
||||
fallback: '안녕하세요, {{name}}님',
|
||||
params: {'name': name},
|
||||
),
|
||||
style: const TextStyle(
|
||||
@@ -672,7 +668,10 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(email, style: TextStyle(color: Colors.grey[600], fontSize: 14)),
|
||||
Text(
|
||||
email,
|
||||
style: TextStyle(color: Colors.grey[600], fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
@@ -680,9 +679,12 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
children: [
|
||||
_buildInfoChip(
|
||||
Icons.badge_outlined,
|
||||
tr('ui.userfront.profile.manage', fallback: '프로필 관리'),
|
||||
tr('ui.userfront.profile.manage'),
|
||||
),
|
||||
_buildInfoChip(
|
||||
Icons.apartment,
|
||||
profile.tenant?.name ?? department,
|
||||
),
|
||||
_buildInfoChip(Icons.apartment, profile.tenant?.name ?? department),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -720,7 +722,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
title: Text(label),
|
||||
subtitle: Text(displayValue),
|
||||
trailing: Text(
|
||||
tr('ui.common.read_only', fallback: '읽기 전용'),
|
||||
tr('ui.common.read_only'),
|
||||
style: TextStyle(color: Colors.grey[500], fontSize: 12),
|
||||
),
|
||||
);
|
||||
@@ -744,7 +746,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
subtitle: Text(displayValue),
|
||||
trailing: TextButton(
|
||||
onPressed: isUpdating ? null : () => _startEditing(field, profile),
|
||||
child: Text(tr('ui.common.edit', fallback: '수정')),
|
||||
child: Text(tr('ui.common.edit')),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -772,7 +774,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
const SizedBox(width: 12),
|
||||
OutlinedButton(
|
||||
onPressed: isUpdating ? null : () => _cancelEditing(profile),
|
||||
child: Text(tr('ui.common.cancel', fallback: '취소')),
|
||||
child: Text(tr('ui.common.cancel')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -787,13 +789,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
if (!isEditing) {
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: Text(
|
||||
tr('ui.userfront.profile.phone.title', fallback: '전화번호'),
|
||||
),
|
||||
title: Text(tr('ui.userfront.profile.phone.title')),
|
||||
subtitle: Text(displayValue),
|
||||
trailing: TextButton(
|
||||
onPressed: isUpdating ? null : () => _startEditing('phone', profile),
|
||||
child: Text(tr('ui.common.edit', fallback: '수정')),
|
||||
child: Text(tr('ui.common.edit')),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -802,7 +802,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
tr('ui.userfront.profile.phone.title', fallback: '전화번호'),
|
||||
tr('ui.userfront.profile.phone.title'),
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -832,17 +832,16 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
onPressed: _isVerifying ? null : _sendCode,
|
||||
child: Text(
|
||||
_isCodeSent
|
||||
? tr('ui.common.resend', fallback: '재전송')
|
||||
? tr('ui.common.resend')
|
||||
: tr(
|
||||
'ui.userfront.profile.phone.request_code',
|
||||
fallback: '인증요청',
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
OutlinedButton(
|
||||
onPressed: isUpdating ? null : () => _cancelEditing(profile),
|
||||
child: Text(tr('ui.common.cancel', fallback: '취소')),
|
||||
child: Text(tr('ui.common.cancel')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -862,7 +861,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
border: const OutlineInputBorder(),
|
||||
hintText: tr(
|
||||
'ui.userfront.profile.phone.code_hint',
|
||||
fallback: '인증번호 6자리',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -870,7 +868,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
const SizedBox(width: 8),
|
||||
ElevatedButton(
|
||||
onPressed: _isVerifying ? null : () => _verifyCode(profile),
|
||||
child: Text(tr('ui.common.confirm', fallback: '확인')),
|
||||
child: Text(tr('ui.common.confirm')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -881,7 +879,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
child: Text(
|
||||
tr(
|
||||
'msg.userfront.profile.phone.verify_notice',
|
||||
fallback: '휴대폰 번호를 변경하려면 SMS 인증이 필요합니다.',
|
||||
),
|
||||
style: const TextStyle(color: Colors.orange, fontSize: 12),
|
||||
),
|
||||
@@ -896,14 +893,13 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
tr('ui.userfront.profile.password.title', fallback: '비밀번호 변경'),
|
||||
tr('ui.userfront.profile.password.title'),
|
||||
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w700),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.profile.password.subtitle',
|
||||
fallback: '현재 비밀번호 확인 후 새 비밀번호로 변경합니다.',
|
||||
),
|
||||
style: const TextStyle(color: Color(0xFF6B7280)),
|
||||
),
|
||||
@@ -914,11 +910,14 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.profile.password.current',
|
||||
fallback: '현재 비밀번호',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_showCurrentPassword ? Icons.visibility_off : Icons.visibility),
|
||||
icon: Icon(
|
||||
_showCurrentPassword
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
onPressed: () => setState(() {
|
||||
_showCurrentPassword = !_showCurrentPassword;
|
||||
}),
|
||||
@@ -932,11 +931,12 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.profile.password.new',
|
||||
fallback: '새 비밀번호',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_showNewPassword ? Icons.visibility_off : Icons.visibility),
|
||||
icon: Icon(
|
||||
_showNewPassword ? Icons.visibility_off : Icons.visibility,
|
||||
),
|
||||
onPressed: () => setState(() {
|
||||
_showNewPassword = !_showNewPassword;
|
||||
}),
|
||||
@@ -950,11 +950,14 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
decoration: InputDecoration(
|
||||
labelText: tr(
|
||||
'ui.userfront.profile.password.confirm',
|
||||
fallback: '새 비밀번호 확인',
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_showConfirmPassword ? Icons.visibility_off : Icons.visibility),
|
||||
icon: Icon(
|
||||
_showConfirmPassword
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility,
|
||||
),
|
||||
onPressed: () => setState(() {
|
||||
_showConfirmPassword = !_showConfirmPassword;
|
||||
}),
|
||||
@@ -963,10 +966,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
),
|
||||
if (_passwordError != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
_passwordError!,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
Text(_passwordError!, style: const TextStyle(color: Colors.red)),
|
||||
],
|
||||
if (_passwordSuccess != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
@@ -989,7 +989,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
: Text(
|
||||
tr(
|
||||
'ui.userfront.profile.password.change',
|
||||
fallback: '비밀번호 변경',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -999,7 +998,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
child: Text(
|
||||
tr(
|
||||
'ui.userfront.profile.password.forgot',
|
||||
fallback: '비밀번호를 잊으셨나요?',
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1025,10 +1023,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
_buildHeaderCard(profile),
|
||||
const SizedBox(height: 28),
|
||||
_buildSectionTitle(
|
||||
tr('ui.userfront.profile.section.basic', fallback: '기본 정보'),
|
||||
tr('ui.userfront.profile.section.basic'),
|
||||
tr(
|
||||
'msg.userfront.profile.section.basic',
|
||||
fallback: '계정 기본 정보를 관리합니다.',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
@@ -1037,7 +1034,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
children: [
|
||||
_buildEditableTile(
|
||||
field: 'name',
|
||||
label: tr('ui.userfront.profile.field.name', fallback: '이름'),
|
||||
label: tr(
|
||||
'ui.userfront.profile.field.name',
|
||||
),
|
||||
value: profile.name,
|
||||
profile: profile,
|
||||
isUpdating: isUpdating,
|
||||
@@ -1045,7 +1044,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
),
|
||||
const Divider(height: 24),
|
||||
_buildReadOnlyTile(
|
||||
tr('ui.userfront.profile.field.email', fallback: '이메일'),
|
||||
tr(
|
||||
'ui.userfront.profile.field.email',
|
||||
),
|
||||
profile.email,
|
||||
),
|
||||
const Divider(height: 24),
|
||||
@@ -1055,10 +1056,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
_buildSectionTitle(
|
||||
tr('ui.userfront.profile.section.organization', fallback: '조직 정보'),
|
||||
tr(
|
||||
'ui.userfront.profile.section.organization',
|
||||
),
|
||||
tr(
|
||||
'msg.userfront.profile.section.organization',
|
||||
fallback: '소속 및 구분 정보입니다.',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
@@ -1067,7 +1069,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
children: [
|
||||
_buildEditableTile(
|
||||
field: 'department',
|
||||
label: tr('ui.userfront.profile.field.department', fallback: '소속'),
|
||||
label: tr(
|
||||
'ui.userfront.profile.field.department',
|
||||
),
|
||||
value: profile.department,
|
||||
profile: profile,
|
||||
isUpdating: isUpdating,
|
||||
@@ -1075,7 +1079,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
),
|
||||
const Divider(height: 24),
|
||||
_buildReadOnlyTile(
|
||||
tr('ui.userfront.profile.field.affiliation', fallback: '구분'),
|
||||
tr(
|
||||
'ui.userfront.profile.field.affiliation',
|
||||
),
|
||||
profile.affiliationType,
|
||||
),
|
||||
if (profile.tenant != null) ...[
|
||||
@@ -1083,7 +1089,6 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
_buildReadOnlyTile(
|
||||
tr(
|
||||
'ui.userfront.profile.field.tenant',
|
||||
fallback: '소속 테넌트',
|
||||
),
|
||||
profile.tenant!.name,
|
||||
),
|
||||
@@ -1091,7 +1096,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
if (profile.companyCode.isNotEmpty) ...[
|
||||
const Divider(height: 24),
|
||||
_buildReadOnlyTile(
|
||||
tr('ui.userfront.profile.field.company_code', fallback: '회사코드'),
|
||||
tr(
|
||||
'ui.userfront.profile.field.company_code',
|
||||
),
|
||||
profile.companyCode,
|
||||
),
|
||||
],
|
||||
@@ -1100,10 +1107,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
_buildSectionTitle(
|
||||
tr('ui.userfront.profile.section.security', fallback: '보안'),
|
||||
tr('ui.userfront.profile.section.security'),
|
||||
tr(
|
||||
'msg.userfront.profile.section.security',
|
||||
fallback: '비밀번호를 안전하게 관리합니다.',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
@@ -1132,7 +1138,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
if (profile == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(tr('ui.userfront.nav.profile', fallback: '내 정보')),
|
||||
title: Text(tr('ui.userfront.nav.profile')),
|
||||
),
|
||||
body: profileState.isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
@@ -1143,13 +1149,13 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
Text(
|
||||
tr(
|
||||
'msg.userfront.profile.load_failed',
|
||||
fallback: '정보를 불러올 수 없습니다.',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: () => ref.read(profileProvider.notifier).loadProfile(),
|
||||
child: Text(tr('ui.common.retry', fallback: '재시도')),
|
||||
onPressed: () =>
|
||||
ref.read(profileProvider.notifier).loadProfile(),
|
||||
child: Text(tr('ui.common.retry')),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -1166,7 +1172,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
backgroundColor: _subtle,
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
tr('ui.userfront.app_title', fallback: 'Baron 로그인'),
|
||||
tr('ui.userfront.app_title'),
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
elevation: 0,
|
||||
@@ -1175,17 +1181,17 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.home_outlined),
|
||||
tooltip: tr('ui.userfront.nav.dashboard', fallback: '대시보드'),
|
||||
tooltip: tr('ui.userfront.nav.dashboard'),
|
||||
onPressed: () => context.go('/'),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.qr_code_scanner),
|
||||
tooltip: tr('ui.userfront.nav.qr_scan', fallback: 'QR 스캔'),
|
||||
tooltip: tr('ui.userfront.nav.qr_scan'),
|
||||
onPressed: () => context.push('/scan'),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout),
|
||||
tooltip: tr('ui.userfront.nav.logout', fallback: '로그아웃'),
|
||||
tooltip: tr('ui.userfront.nav.logout'),
|
||||
onPressed: _logout,
|
||||
),
|
||||
],
|
||||
@@ -1193,11 +1199,7 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
|
||||
drawer: isWide ? null : Drawer(child: _buildSideMenu(context)),
|
||||
body: Row(
|
||||
children: [
|
||||
if (isWide)
|
||||
SizedBox(
|
||||
width: 240,
|
||||
child: _buildSideMenu(context),
|
||||
),
|
||||
if (isWide) SizedBox(width: 240, child: _buildSideMenu(context)),
|
||||
Expanded(child: _buildContent(profile, isUpdating)),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,40 +1,18 @@
|
||||
import 'dart:ui';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
|
||||
import 'i18n_data.dart';
|
||||
final _koreanPattern = RegExp(r'[가-힣]');
|
||||
|
||||
const _defaultLocale = 'ko';
|
||||
const _supportedLocales = ['ko', 'en'];
|
||||
|
||||
String _resolveLocale() {
|
||||
final locale = PlatformDispatcher.instance.locale;
|
||||
final code = locale.languageCode.toLowerCase();
|
||||
if (_supportedLocales.contains(code)) {
|
||||
return code;
|
||||
String tr(String key, {String? fallback, Map<String, String>? params}) {
|
||||
try {
|
||||
if (fallback != null && _koreanPattern.hasMatch(fallback)) {
|
||||
fallback = null;
|
||||
}
|
||||
final translated = key.tr(namedArgs: params);
|
||||
if (translated == key && fallback != null && fallback.isNotEmpty) {
|
||||
return fallback;
|
||||
}
|
||||
return translated;
|
||||
} catch (_) {
|
||||
return fallback ?? key;
|
||||
}
|
||||
return _defaultLocale;
|
||||
}
|
||||
|
||||
String _formatTemplate(String template, Map<String, String>? params) {
|
||||
if (params == null || params.isEmpty) {
|
||||
return template;
|
||||
}
|
||||
var result = template;
|
||||
params.forEach((key, value) {
|
||||
result = result.replaceAll('{{$key}}', value);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
String tr(
|
||||
String key, {
|
||||
String? fallback,
|
||||
Map<String, String>? params,
|
||||
}) {
|
||||
final locale = _resolveLocale();
|
||||
final map = locale == 'en' ? enStrings : koStrings;
|
||||
final value = map[key];
|
||||
final template = (value != null && value.isNotEmpty)
|
||||
? value
|
||||
: (fallback ?? key);
|
||||
return _formatTemplate(template, params);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:easy_localization/easy_localization.dart' hide tr;
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_web_plugins/url_strategy.dart';
|
||||
@@ -19,6 +20,9 @@ import 'core/services/auth_proxy_service.dart';
|
||||
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_utils.dart';
|
||||
import 'core/i18n/toml_asset_loader.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'features/auth/presentation/consent_screen.dart';
|
||||
import 'i18n.dart';
|
||||
@@ -40,13 +44,16 @@ Future<void> _loadBundledFonts() async {
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
usePathUrlStrategy();
|
||||
await EasyLocalization.ensureInitialized();
|
||||
|
||||
// 1. Global Error Handling
|
||||
FlutterError.onError = (details) {
|
||||
FlutterError.presentError(details);
|
||||
_log.severe("FLUTTER_ERROR", details.exception, details.stack);
|
||||
// Also send to backend if needed
|
||||
AuthProxyService.logError("FLUTTER_ERROR: ${details.exception}\n${details.stack}");
|
||||
AuthProxyService.logError(
|
||||
"FLUTTER_ERROR: ${details.exception}\n${details.stack}",
|
||||
);
|
||||
};
|
||||
|
||||
PlatformDispatcher.instance.onError = (error, stack) {
|
||||
@@ -68,7 +75,22 @@ void main() async {
|
||||
// 폰트를 먼저 로딩해서 렌더링 깨짐(FOIT/FOUT) 최소화
|
||||
await _loadBundledFonts();
|
||||
|
||||
runApp(const ProviderScope(child: BaronSSOApp()));
|
||||
runApp(
|
||||
// URL(/en, /ko)이 있으면 우선 적용해서 첫 렌더부터 올바른 언어로 시작합니다.
|
||||
() {
|
||||
final initialLocaleCode =
|
||||
extractLocaleFromPath(Uri.base) ?? resolvePreferredLocaleCode();
|
||||
return EasyLocalization(
|
||||
supportedLocales: const [Locale('en'), Locale('ko')],
|
||||
fallbackLocale: const Locale('en'),
|
||||
startLocale: Locale(initialLocaleCode),
|
||||
saveLocale: false,
|
||||
path: 'assets/translations',
|
||||
assetLoader: const TomlAssetLoader(),
|
||||
child: const ProviderScope(child: BaronSSOApp()),
|
||||
);
|
||||
}(),
|
||||
);
|
||||
}
|
||||
|
||||
// Router Configuration
|
||||
@@ -79,190 +101,227 @@ final _router = GoRouter(
|
||||
debugLogDiagnostics: !kReleaseMode,
|
||||
refreshListenable: AuthNotifier.instance,
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to root (DashboardScreen)");
|
||||
return const DashboardScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/profile',
|
||||
builder: (context, state) => const ProfilePage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/signin',
|
||||
builder: (context, state) {
|
||||
final loginChallenge = state.uri.queryParameters['login_challenge'];
|
||||
_routerLogger.info("Navigating to /signin with login_challenge: $loginChallenge");
|
||||
return LoginScreen(key: state.pageKey, loginChallenge: loginChallenge);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/login',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /login");
|
||||
return LoginScreen(key: state.pageKey);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/consent',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
final consentChallenge = state.uri.queryParameters['consent_challenge'];
|
||||
if (consentChallenge == null) {
|
||||
_routerLogger.warning("Consent screen loaded without a challenge.");
|
||||
return const Scaffold(body: Center(child: Text('Error: Consent challenge is missing.')));
|
||||
}
|
||||
_routerLogger.info("Navigating to /consent with challenge.");
|
||||
return ConsentScreen(consentChallenge: consentChallenge);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/signup',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /signup");
|
||||
return const SignupScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/registration',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /registration");
|
||||
return const SignupScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/verify',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /verify (query)");
|
||||
return LoginScreen(key: state.pageKey);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/verify/:token',
|
||||
builder: (context, state) {
|
||||
final token = state.pathParameters['token'];
|
||||
_routerLogger.info("Navigating to /verify with token: $token");
|
||||
return LoginScreen(key: state.pageKey, verificationToken: token);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/verification',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /verification");
|
||||
return LoginScreen(key: state.pageKey);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/l/:shortCode',
|
||||
builder: (context, state) {
|
||||
final shortCode = state.pathParameters['shortCode'];
|
||||
_routerLogger.info("Navigating to /l with code: $shortCode");
|
||||
return LoginScreen(key: state.pageKey);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/forgot-password',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /forgot-password");
|
||||
return const ForgotPasswordScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/recovery',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /recovery");
|
||||
return const ForgotPasswordScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
// Supports both /reset-password and /reset-password?token=...
|
||||
path: '/reset-password',
|
||||
builder: (context, state) {
|
||||
// For deep linking, you might pass the token in the path, e.g., /reset-password/:token
|
||||
// final token = state.pathParameters['token'];
|
||||
_routerLogger.info("Navigating to /reset-password");
|
||||
return const ResetPasswordScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/error',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /error");
|
||||
final params = state.uri.queryParameters;
|
||||
return ErrorScreen(
|
||||
errorId: params['id'],
|
||||
errorCode: params['error'],
|
||||
description: params['error_description'] ?? params['message'],
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/settings',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /settings (disabled)");
|
||||
return ErrorScreen(
|
||||
errorCode: 'settings_disabled',
|
||||
description: tr(
|
||||
'msg.userfront.settings.disabled',
|
||||
fallback: '현재 계정 설정 화면은 준비 중입니다.',
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/approve',
|
||||
builder: (context, state) {
|
||||
final ref = state.uri.queryParameters['ref'];
|
||||
_routerLogger.info("Navigating to /approve with ref: $ref");
|
||||
return ApproveQrScreen(pendingRef: ref);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/ql/:ref',
|
||||
builder: (context, state) {
|
||||
final ref = state.pathParameters['ref'];
|
||||
_routerLogger.info("Navigating to /ql with ref: $ref");
|
||||
return ApproveQrScreen(pendingRef: ref);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/scan',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /scan");
|
||||
return const QRScanScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/admin/users',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /admin/users");
|
||||
return const UserManagementScreen();
|
||||
ShellRoute(
|
||||
builder: (context, state, child) {
|
||||
final localeCode =
|
||||
extractLocaleFromPath(state.uri) ?? resolvePreferredLocaleCode();
|
||||
return LocaleGate(localeCode: localeCode, child: child);
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/:locale',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to root (DashboardScreen)");
|
||||
return const DashboardScreen();
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'profile',
|
||||
builder: (context, state) => const ProfilePage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'signin',
|
||||
builder: (context, state) {
|
||||
final loginChallenge =
|
||||
state.uri.queryParameters['login_challenge'];
|
||||
final redirectUrl =
|
||||
state.uri.queryParameters['redirect_uri'] ??
|
||||
state.uri.queryParameters['redirect_url'];
|
||||
_routerLogger.info(
|
||||
"Navigating to /signin with login_challenge: $loginChallenge, redirect: $redirectUrl",
|
||||
);
|
||||
return LoginScreen(
|
||||
key: state.pageKey,
|
||||
loginChallenge: loginChallenge,
|
||||
redirectUrl: redirectUrl,
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'login',
|
||||
builder: (context, state) {
|
||||
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);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'consent',
|
||||
builder: (BuildContext context, GoRouterState state) {
|
||||
final consentChallenge =
|
||||
state.uri.queryParameters['consent_challenge'];
|
||||
if (consentChallenge == null) {
|
||||
_routerLogger.warning("Consent screen loaded without a challenge.");
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: Text('Error: Consent challenge is missing.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
_routerLogger.info("Navigating to /consent with challenge.");
|
||||
return ConsentScreen(consentChallenge: consentChallenge);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'signup',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /signup");
|
||||
return const SignupScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'registration',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /registration");
|
||||
return const SignupScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'verify',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /verify (query)");
|
||||
return LoginScreen(key: state.pageKey);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'verify/:token',
|
||||
builder: (context, state) {
|
||||
final token = state.pathParameters['token'];
|
||||
_routerLogger.info("Navigating to /verify with token: $token");
|
||||
return LoginScreen(
|
||||
key: state.pageKey,
|
||||
verificationToken: token,
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'verification',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /verification");
|
||||
return LoginScreen(key: state.pageKey);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'l/:shortCode',
|
||||
builder: (context, state) {
|
||||
final shortCode = state.pathParameters['shortCode'];
|
||||
_routerLogger.info("Navigating to /l with code: $shortCode");
|
||||
return LoginScreen(key: state.pageKey);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'forgot-password',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /forgot-password");
|
||||
return const ForgotPasswordScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'recovery',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /recovery");
|
||||
return const ForgotPasswordScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
// Supports both /reset-password and /reset-password?token=...
|
||||
path: 'reset-password',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /reset-password");
|
||||
return const ResetPasswordScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'error',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /error");
|
||||
final params = state.uri.queryParameters;
|
||||
return ErrorScreen(
|
||||
errorId: params['id'],
|
||||
errorCode: params['error'],
|
||||
description:
|
||||
params['error_description'] ?? params['message'],
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'settings',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /settings (disabled)");
|
||||
return ErrorScreen(
|
||||
errorCode: 'settings_disabled',
|
||||
description: tr(
|
||||
'msg.userfront.settings.disabled',
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'approve',
|
||||
builder: (context, state) {
|
||||
final ref = state.uri.queryParameters['ref'];
|
||||
_routerLogger.info("Navigating to /approve with ref: $ref");
|
||||
return ApproveQrScreen(pendingRef: ref);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'ql/:ref',
|
||||
builder: (context, state) {
|
||||
final ref = state.pathParameters['ref'];
|
||||
_routerLogger.info("Navigating to /ql with ref: $ref");
|
||||
return ApproveQrScreen(pendingRef: ref);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'scan',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /scan");
|
||||
return const QRScanScreen();
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: 'admin/users',
|
||||
builder: (context, state) {
|
||||
_routerLogger.info("Navigating to /admin/users");
|
||||
return const UserManagementScreen();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
redirect: (context, state) {
|
||||
final requestedLocale = extractLocaleFromPath(state.uri);
|
||||
final preferredLocale = resolvePreferredLocaleCode();
|
||||
if (requestedLocale == null) {
|
||||
return buildLocalizedPath(preferredLocale, state.uri);
|
||||
}
|
||||
|
||||
final hasStoredToken = AuthTokenStore.getToken() != null;
|
||||
final hasCookieSession = AuthTokenStore.usesCookie();
|
||||
final isLoggedIn = hasStoredToken || hasCookieSession;
|
||||
final path = state.uri.path;
|
||||
final path = stripLocalePath(state.uri);
|
||||
|
||||
// Public paths that don't require login
|
||||
final isPublicPath = path == '/signin' ||
|
||||
path == '/signup' ||
|
||||
path == '/login' ||
|
||||
path == '/registration' ||
|
||||
path == '/verify' ||
|
||||
path == '/verification' ||
|
||||
path.startsWith('/verify/') ||
|
||||
path == '/approve' ||
|
||||
path.startsWith('/ql/') ||
|
||||
path == '/forgot-password' ||
|
||||
path == '/recovery' ||
|
||||
path == '/reset-password' ||
|
||||
path == '/error' ||
|
||||
path == '/settings' ||
|
||||
path == '/consent'; // Consent page is public
|
||||
final isPublicPath =
|
||||
path == '/signin' ||
|
||||
path == '/signup' ||
|
||||
path == '/login' ||
|
||||
path == '/registration' ||
|
||||
path == '/verify' ||
|
||||
path == '/verification' ||
|
||||
path.startsWith('/verify/') ||
|
||||
path == '/approve' ||
|
||||
path.startsWith('/ql/') ||
|
||||
path == '/forgot-password' ||
|
||||
path == '/recovery' ||
|
||||
path == '/reset-password' ||
|
||||
path == '/error' ||
|
||||
path == '/settings' ||
|
||||
path == '/consent'; // Consent page is public
|
||||
|
||||
_routerLogger.fine("Redirect check - Path: $path, IsLoggedIn: $isLoggedIn");
|
||||
|
||||
@@ -273,13 +332,14 @@ 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");
|
||||
_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 '/signin?login_challenge=$loginChallenge';
|
||||
return '/$locale/signin?login_challenge=$loginChallenge';
|
||||
}
|
||||
return '/signin';
|
||||
return '/$locale/signin';
|
||||
}
|
||||
|
||||
// If logged in and trying to access login page, redirect to root (dashboard)
|
||||
@@ -299,7 +359,10 @@ class BaronSSOApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp.router(
|
||||
title: tr('ui.userfront.app_title', fallback: 'Baron 로그인'),
|
||||
title: tr('ui.userfront.app_title'),
|
||||
localizationsDelegates: context.localizationDelegates,
|
||||
supportedLocales: context.supportedLocales,
|
||||
locale: context.locale,
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: const Color(0xFF1A1F2C), // Dark Navy/Black base
|
||||
|
||||
@@ -105,6 +105,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.8"
|
||||
easy_localization:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: easy_localization
|
||||
sha256: "2ccdf9db8fe4d9c5a75c122e6275674508fd0f0d49c827354967b8afcc56bbed"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.8"
|
||||
easy_logger:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: easy_logger
|
||||
sha256: c764a6e024846f33405a2342caf91c62e357c24b02c04dbc712ef232bf30ffb7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.2"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -113,6 +129,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.3"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -134,6 +158,11 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.0"
|
||||
flutter_driver:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -142,6 +171,11 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.0"
|
||||
flutter_localizations:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_riverpod:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -168,6 +202,11 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
fuchsia_remote_debug_protocol:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -208,6 +247,19 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.2"
|
||||
integration_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: intl
|
||||
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.20.2"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -336,6 +388,46 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.1"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_linux
|
||||
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
path_provider_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_windows
|
||||
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
sha256: "07c8f0b1913bcde1ff0d26e57ace2f3012ccbf2b204e070290dad3bb22797646"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.0"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.6"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -352,6 +444,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.2"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: process
|
||||
sha256: c6248e4526673988586e8c00bb22a49210c258dc91df5227d5da9748ecf79744
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.5"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -384,6 +484,62 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
shared_preferences:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences
|
||||
sha256: "2939ae520c9024cb197fc20dee269cd8cdbf564c8b5746374ec6cacdc5169e64"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.4"
|
||||
shared_preferences_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_android
|
||||
sha256: cbc40be9be1c5af4dab4d6e0de4d5d3729e6f3d65b89d21e1815d57705644a6f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.20"
|
||||
shared_preferences_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_foundation
|
||||
sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.6"
|
||||
shared_preferences_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_linux
|
||||
sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
shared_preferences_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_platform_interface
|
||||
sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
shared_preferences_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_web
|
||||
sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.3"
|
||||
shared_preferences_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_windows
|
||||
sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
shelf:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -477,6 +633,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.1"
|
||||
sync_http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sync_http
|
||||
sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.1"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -509,6 +673,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.12"
|
||||
toml:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: toml
|
||||
sha256: "9968de24e45b632bf1a654fe1ac7b6fe5261c349243df83fd262397799c45a2d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.15.0"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -629,6 +801,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
webdriver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webdriver
|
||||
sha256: "2f3a14ca026957870cfd9c635b83507e0e51d8091568e90129fbf805aba7cade"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.0"
|
||||
webkit_inspection_protocol:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -637,6 +817,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -646,5 +834,5 @@ packages:
|
||||
source: hosted
|
||||
version: "3.1.3"
|
||||
sdks:
|
||||
dart: ">=3.10.4 <4.0.0"
|
||||
dart: ">=3.10.0 <4.0.0"
|
||||
flutter: ">=3.38.0"
|
||||
|
||||
@@ -19,7 +19,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ^3.10.4
|
||||
sdk: ">=3.10.0-0 <4.0.0"
|
||||
|
||||
# Dependencies specify other packages that your package needs in order to work.
|
||||
# To automatically upgrade your package dependencies to the latest versions
|
||||
@@ -45,10 +45,14 @@ dependencies:
|
||||
logger: ^2.0.0
|
||||
qr_flutter: ^4.1.0
|
||||
mobile_scanner: ^7.1.4
|
||||
easy_localization: ^3.0.7
|
||||
toml: ^0.15.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
integration_test:
|
||||
sdk: flutter
|
||||
|
||||
# The "flutter_lints" package below contains a set of recommended lints to
|
||||
# encourage good coding practices. The lint set provided by the package is
|
||||
@@ -70,6 +74,8 @@ flutter:
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
# - .env
|
||||
assets:
|
||||
- assets/translations/
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/to/resolution-aware-images
|
||||
|
||||
5
userfront/test/helpers/web_storage.dart
Normal file
5
userfront/test/helpers/web_storage.dart
Normal file
@@ -0,0 +1,5 @@
|
||||
import 'web_storage_stub.dart'
|
||||
if (dart.library.html) 'web_storage_web.dart';
|
||||
|
||||
export 'web_storage_stub.dart'
|
||||
if (dart.library.html) 'web_storage_web.dart';
|
||||
21
userfront/test/helpers/web_storage_stub.dart
Normal file
21
userfront/test/helpers/web_storage_stub.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
class WebStorage {
|
||||
bool get isWeb => false;
|
||||
|
||||
String? get(String key) => null;
|
||||
|
||||
void set(String key, String value) {}
|
||||
|
||||
String? getSession(String key) => null;
|
||||
|
||||
void setSession(String key, String value) {}
|
||||
|
||||
void removeSession(String key) {}
|
||||
|
||||
void clearSession() {}
|
||||
|
||||
void remove(String key) {}
|
||||
|
||||
void clear() {}
|
||||
}
|
||||
|
||||
final webStorage = WebStorage();
|
||||
37
userfront/test/helpers/web_storage_web.dart
Normal file
37
userfront/test/helpers/web_storage_web.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
// ignore_for_file: avoid_web_libraries_in_flutter
|
||||
|
||||
import 'dart:html' as html;
|
||||
|
||||
class WebStorage {
|
||||
bool get isWeb => true;
|
||||
|
||||
String? get(String key) => html.window.localStorage[key];
|
||||
|
||||
void set(String key, String value) {
|
||||
html.window.localStorage[key] = value;
|
||||
}
|
||||
|
||||
String? getSession(String key) => html.window.sessionStorage[key];
|
||||
|
||||
void setSession(String key, String value) {
|
||||
html.window.sessionStorage[key] = value;
|
||||
}
|
||||
|
||||
void removeSession(String key) {
|
||||
html.window.sessionStorage.remove(key);
|
||||
}
|
||||
|
||||
void clearSession() {
|
||||
html.window.sessionStorage.clear();
|
||||
}
|
||||
|
||||
void remove(String key) {
|
||||
html.window.localStorage.remove(key);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
html.window.localStorage.clear();
|
||||
}
|
||||
}
|
||||
|
||||
final webStorage = WebStorage();
|
||||
88
userfront/test/locale_storage_web_test.dart
Normal file
88
userfront/test/locale_storage_web_test.dart
Normal file
@@ -0,0 +1,88 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:userfront/core/i18n/locale_storage.dart';
|
||||
import 'package:userfront/core/i18n/locale_storage_web.dart' as locale_web;
|
||||
|
||||
import 'helpers/web_storage.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
locale_web.LocaleStorageImpl.forceMemoryStorageForTests(false);
|
||||
locale_web.LocaleStorageImpl.forceSessionStorageForTests(false);
|
||||
if (webStorage.isWeb) {
|
||||
webStorage.clear();
|
||||
webStorage.clearSession();
|
||||
}
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
locale_web.LocaleStorageImpl.forceMemoryStorageForTests(false);
|
||||
locale_web.LocaleStorageImpl.forceSessionStorageForTests(false);
|
||||
if (webStorage.isWeb) {
|
||||
webStorage.clear();
|
||||
webStorage.clearSession();
|
||||
}
|
||||
});
|
||||
|
||||
test(
|
||||
'localStorage write/read (웹)',
|
||||
() {
|
||||
if (!webStorage.isWeb) {
|
||||
return;
|
||||
}
|
||||
|
||||
LocaleStorage.write('ko');
|
||||
expect(webStorage.get('locale'), 'ko');
|
||||
expect(LocaleStorage.read(), 'ko');
|
||||
},
|
||||
skip: !webStorage.isWeb,
|
||||
);
|
||||
|
||||
test(
|
||||
'legacy key에서 locale로 마이그레이션 (웹)',
|
||||
() {
|
||||
if (!webStorage.isWeb) {
|
||||
return;
|
||||
}
|
||||
|
||||
webStorage.set('baron_locale', 'en');
|
||||
expect(LocaleStorage.read(), 'en');
|
||||
expect(webStorage.get('locale'), 'en');
|
||||
expect(webStorage.get('baron_locale'), isNull);
|
||||
},
|
||||
skip: !webStorage.isWeb,
|
||||
);
|
||||
|
||||
test(
|
||||
'localStorage 접근이 차단되면 메모리 fallback (웹)',
|
||||
() {
|
||||
if (!webStorage.isWeb) {
|
||||
return;
|
||||
}
|
||||
|
||||
locale_web.LocaleStorageImpl.forceMemoryStorageForTests(true);
|
||||
|
||||
LocaleStorage.write('en');
|
||||
expect(webStorage.get('locale'), isNull);
|
||||
expect(webStorage.getSession('locale'), isNull);
|
||||
expect(LocaleStorage.read(), 'en');
|
||||
},
|
||||
skip: !webStorage.isWeb,
|
||||
);
|
||||
|
||||
test(
|
||||
'localStorage 접근이 차단되면 sessionStorage로 fallback (웹)',
|
||||
() {
|
||||
if (!webStorage.isWeb) {
|
||||
return;
|
||||
}
|
||||
|
||||
locale_web.LocaleStorageImpl.forceSessionStorageForTests(true);
|
||||
|
||||
LocaleStorage.write('ko');
|
||||
expect(webStorage.get('locale'), isNull);
|
||||
expect(webStorage.getSession('locale'), 'ko');
|
||||
expect(LocaleStorage.read(), 'ko');
|
||||
},
|
||||
skip: !webStorage.isWeb,
|
||||
);
|
||||
}
|
||||
66
userfront/test/locale_utils_test.dart
Normal file
66
userfront/test/locale_utils_test.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:userfront/core/i18n/locale_utils.dart';
|
||||
|
||||
void main() {
|
||||
group('locale_utils', () {
|
||||
test('normalizeLocaleCode handles supported locales', () {
|
||||
expect(normalizeLocaleCode('ko'), 'ko');
|
||||
expect(normalizeLocaleCode('ko-KR'), 'ko');
|
||||
expect(normalizeLocaleCode('en'), 'en');
|
||||
expect(normalizeLocaleCode('en-US'), 'en');
|
||||
});
|
||||
|
||||
test('normalizeLocaleCode falls back to default', () {
|
||||
expect(normalizeLocaleCode('ja'), defaultLocaleCode);
|
||||
expect(normalizeLocaleCode(null), defaultLocaleCode);
|
||||
expect(normalizeLocaleCode(''), defaultLocaleCode);
|
||||
});
|
||||
|
||||
test('extractLocaleFromPath picks locale when present', () {
|
||||
expect(extractLocaleFromPath(Uri.parse('/ko/signin')), 'ko');
|
||||
expect(extractLocaleFromPath(Uri.parse('/en/profile')), 'en');
|
||||
expect(extractLocaleFromPath(Uri.parse('/ko')), 'ko');
|
||||
});
|
||||
|
||||
test('extractLocaleFromPath returns null when missing', () {
|
||||
expect(extractLocaleFromPath(Uri.parse('/signin')), isNull);
|
||||
expect(extractLocaleFromPath(Uri.parse('/zz/signin')), isNull);
|
||||
});
|
||||
|
||||
test('stripLocalePath removes locale segment', () {
|
||||
expect(stripLocalePath(Uri.parse('/ko/signin')), '/signin');
|
||||
expect(stripLocalePath(Uri.parse('/en/profile')), '/profile');
|
||||
expect(stripLocalePath(Uri.parse('/ko')), '/');
|
||||
expect(stripLocalePath(Uri.parse('/en/')), '/');
|
||||
});
|
||||
|
||||
test('stripLocalePath keeps path without locale', () {
|
||||
expect(stripLocalePath(Uri.parse('/signin')), '/signin');
|
||||
expect(stripLocalePath(Uri.parse('/auth/callback')), '/auth/callback');
|
||||
});
|
||||
|
||||
test('buildLocalizedPath applies locale', () {
|
||||
expect(buildLocalizedPath('ko', Uri.parse('/signin')), '/ko/signin');
|
||||
expect(buildLocalizedPath('en', Uri.parse('/signin')), '/en/signin');
|
||||
expect(buildLocalizedPath('ko', Uri.parse('/')), '/ko');
|
||||
expect(buildLocalizedPath('en', Uri.parse('/')), '/en');
|
||||
});
|
||||
|
||||
test('buildLocalizedPath preserves query parameters', () {
|
||||
final uri = Uri.parse('/signin?redirect_uri=https://example.com');
|
||||
expect(
|
||||
buildLocalizedPath('ko', uri),
|
||||
'/ko/signin?redirect_uri=https%3A%2F%2Fexample.com',
|
||||
);
|
||||
});
|
||||
|
||||
test('buildLocalizedPath replaces existing locale', () {
|
||||
expect(buildLocalizedPath('en', Uri.parse('/ko/signin')), '/en/signin');
|
||||
expect(buildLocalizedPath('ko', Uri.parse('/en/profile')), '/ko/profile');
|
||||
});
|
||||
|
||||
test('buildLocalizedPath drops unknown 2-letter prefix', () {
|
||||
expect(buildLocalizedPath('ko', Uri.parse('/zz/signin')), '/ko/signin');
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -5,15 +5,36 @@
|
||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||
// tree, read text, and verify that the values of widget properties are correct.
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:userfront/main.dart' show BaronSSOApp;
|
||||
|
||||
class _TestAssetLoader extends AssetLoader {
|
||||
const _TestAssetLoader();
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> load(String path, Locale locale) async {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('BaronSSOApp builds', (WidgetTester tester) async {
|
||||
// runApp에서 ProviderScope로 감싸서 쓰고 있으니 테스트도 동일하게 감쌈
|
||||
await tester.pumpWidget(const ProviderScope(child: BaronSSOApp()));
|
||||
await tester.pumpWidget(
|
||||
EasyLocalization(
|
||||
supportedLocales: const [Locale('en'), Locale('ko')],
|
||||
fallbackLocale: const Locale('en'),
|
||||
startLocale: const Locale('en'),
|
||||
path: 'assets/translations',
|
||||
assetLoader: const _TestAssetLoader(),
|
||||
child: const ProviderScope(child: BaronSSOApp()),
|
||||
),
|
||||
);
|
||||
await tester.pump(); // 한 프레임 더
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user