From 8ba4af4945fb2d4b461eda149ea57c81df3ec48d Mon Sep 17 00:00:00 2001 From: kyy Date: Tue, 27 Jan 2026 12:17:07 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20+82=20=ED=9B=84=EC=B2=98=EB=A6=AC?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/create_user_screen.dart | 20 ++++++++++-- .../presentation/user_management_screen.dart | 32 +++++++++++++++++-- .../presentation/forgot_password_screen.dart | 14 ++++++-- .../auth/presentation/login_screen.dart | 13 ++++++-- 4 files changed, 70 insertions(+), 9 deletions(-) diff --git a/frontend/lib/features/admin/presentation/create_user_screen.dart b/frontend/lib/features/admin/presentation/create_user_screen.dart index da5337ea..69418cfc 100644 --- a/frontend/lib/features/admin/presentation/create_user_screen.dart +++ b/frontend/lib/features/admin/presentation/create_user_screen.dart @@ -108,12 +108,28 @@ class _CreateUserScreenState extends State { setState(() => _isLoading = true); + String loginId = _loginIdController.text.trim(); + if (!loginId.contains('@')) { + loginId = loginId.replaceAll(RegExp(r'[-\s]'), ''); + if (loginId.startsWith('010')) { + loginId = '+82${loginId.substring(1)}'; + } + } + + String? phone = _phoneController.text.trim().isEmpty ? null : _phoneController.text.trim(); + if (phone != null && !phone.contains('@')) { + phone = phone.replaceAll(RegExp(r'[-\s]'), ''); + if (phone.startsWith('010')) { + phone = '+82${phone.substring(1)}'; + } + } + try { await AuthProxyService.createUser( - loginId: _loginIdController.text.trim(), + loginId: loginId, adminPassword: _verifiedAdminPassword!, email: _emailController.text.trim().isEmpty ? null : _emailController.text.trim(), - phone: _phoneController.text.trim().isEmpty ? null : _phoneController.text.trim(), + phone: phone, displayName: _nameController.text.trim().isEmpty ? null : _nameController.text.trim(), ); diff --git a/frontend/lib/features/admin/presentation/user_management_screen.dart b/frontend/lib/features/admin/presentation/user_management_screen.dart index f779e779..f61f94fb 100644 --- a/frontend/lib/features/admin/presentation/user_management_screen.dart +++ b/frontend/lib/features/admin/presentation/user_management_screen.dart @@ -205,13 +205,22 @@ class _UserManagementScreenState extends State with Single if (confirm != true) return; setState(() => _isLoading = true); + + String? phone = phoneController.text.trim().isEmpty ? null : phoneController.text.trim(); + if (phone != null && !phone.contains('@')) { + phone = phone.replaceAll(RegExp(r'[-\s]'), ''); + if (phone.startsWith('010')) { + phone = '+82${phone.substring(1)}'; + } + } + try { await AuthProxyService.updateUserDetails( adminPassword: _verifiedAdminPassword!, loginId: loginId, displayName: nameController.text.trim(), email: emailController.text.trim(), - phone: phoneController.text.trim(), + phone: phone, ); _showSuccess("User updated successfully"); _loadUsers(query: _searchController.text); @@ -228,12 +237,29 @@ class _UserManagementScreenState extends State with Single if (_verifiedAdminPassword == null) return; setState(() => _isLoading = true); + + String loginId = _createLoginIdController.text.trim(); + if (!loginId.contains('@')) { + loginId = loginId.replaceAll(RegExp(r'[-\s]'), ''); + if (loginId.startsWith('010')) { + loginId = '+82${loginId.substring(1)}'; + } + } + + String? phone = _createPhoneController.text.trim().isEmpty ? null : _createPhoneController.text.trim(); + if (phone != null && !phone.contains('@')) { + phone = phone.replaceAll(RegExp(r'[-\s]'), ''); + if (phone.startsWith('010')) { + phone = '+82${phone.substring(1)}'; + } + } + try { await AuthProxyService.createUser( - loginId: _createLoginIdController.text.trim(), + loginId: loginId, adminPassword: _verifiedAdminPassword!, email: _createEmailController.text.trim().isEmpty ? null : _createEmailController.text.trim(), - phone: _createPhoneController.text.trim().isEmpty ? null : _createPhoneController.text.trim(), + phone: phone, displayName: _createNameController.text.trim().isEmpty ? null : _createNameController.text.trim(), ); diff --git a/frontend/lib/features/auth/presentation/forgot_password_screen.dart b/frontend/lib/features/auth/presentation/forgot_password_screen.dart index 0b80e708..ae2b82e7 100644 --- a/frontend/lib/features/auth/presentation/forgot_password_screen.dart +++ b/frontend/lib/features/auth/presentation/forgot_password_screen.dart @@ -14,15 +14,25 @@ class _ForgotPasswordScreenState extends State { bool _isLoading = false; Future _handlePasswordReset() async { - if (_loginIdController.text.trim().isEmpty) { + final input = _loginIdController.text.trim(); + if (input.isEmpty) { _showError("이메일 또는 휴대폰 번호를 입력해주세요."); return; } + String loginId = input; + if (!input.contains('@')) { + // Format phone number if it's not an email + loginId = input.replaceAll(RegExp(r'[-\s]'), ''); + if (loginId.startsWith('010')) { + loginId = '+82${loginId.substring(1)}'; + } + } + setState(() => _isLoading = true); try { - await AuthProxyService.initiatePasswordReset(_loginIdController.text.trim()); + await AuthProxyService.initiatePasswordReset(loginId); if (mounted) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( diff --git a/frontend/lib/features/auth/presentation/login_screen.dart b/frontend/lib/features/auth/presentation/login_screen.dart index 78390bbe..e2fefbf0 100644 --- a/frontend/lib/features/auth/presentation/login_screen.dart +++ b/frontend/lib/features/auth/presentation/login_screen.dart @@ -245,13 +245,22 @@ class _LoginScreenState extends ConsumerState // 이메일/비밀번호 로그인 처리 Future _handlePasswordLogin() async { - final loginId = _passwordLoginIdController.text.trim(); + final input = _passwordLoginIdController.text.trim(); final password = _passwordController.text.trim(); - if (loginId.isEmpty || password.isEmpty) { + if (input.isEmpty || password.isEmpty) { _showError("이메일(또는 전화번호)와 비밀번호를 모두 입력해주세요."); return; } + String loginId = input; + if (!input.contains('@')) { + // Format phone number if it's not an email + loginId = input.replaceAll(RegExp(r'[-\s]'), ''); + if (loginId.startsWith('010')) { + loginId = '+82${loginId.substring(1)}'; + } + } + // 로딩 인디케이터 표시 showDialog( context: context,