From c4b86f77f109ce555a0e9e94e0d871ebc6d2830a Mon Sep 17 00:00:00 2001 From: kyy Date: Tue, 6 Jan 2026 16:33:21 +0900 Subject: [PATCH] =?UTF-8?q?SMS=20=EC=9D=B8=EC=A6=9D=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EB=B0=9C=EC=86=A1=20=EB=B0=8F=20=EA=B2=80=EC=A6=9D=20UI/?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/core/services/auth_proxy_service.dart | 19 ++++++++++++++++++ .../auth/presentation/login_screen.dart | 20 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/frontend/lib/core/services/auth_proxy_service.dart b/frontend/lib/core/services/auth_proxy_service.dart index 470a4255..ec57a56c 100644 --- a/frontend/lib/core/services/auth_proxy_service.dart +++ b/frontend/lib/core/services/auth_proxy_service.dart @@ -74,6 +74,25 @@ class AuthProxyService { } } + static Future> 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, + }), + ); + + if (response.statusCode == 200) { + return jsonDecode(response.body); + } else { + throw Exception('Failed to verify code: ${response.body}'); + } + } + static Future logError(String message) async { final url = Uri.parse('$_baseUrl/api/v1/client-log'); try { diff --git a/frontend/lib/features/auth/presentation/login_screen.dart b/frontend/lib/features/auth/presentation/login_screen.dart index cf718054..7487738b 100644 --- a/frontend/lib/features/auth/presentation/login_screen.dart +++ b/frontend/lib/features/auth/presentation/login_screen.dart @@ -235,19 +235,35 @@ class _LoginScreenState extends ConsumerState final phone = _phoneController.text.trim(); if (phone.isEmpty) return; + print("[Frontend] SMS 코드 발송 시작. 번호: $phone"); try { await AuthProxyService.sendSms(phone); + print("[Frontend] SMS 코드 발송 요청 성공."); setState(() { _smsSent = true; }); } catch (e) { + print("[Frontend] SMS 코드 발송 요청 실패: $e"); _showError("Failed to send SMS: $e"); } } Future _handleSmsVerification() async { - // For now, just show a success message - _showSuccessDialog(); + final phone = _phoneController.text.trim(); + final code = _smsCodeController.text.trim(); + if (phone.isEmpty || code.isEmpty) return; + + print("[Frontend] SMS 코드 검증 시작. 번호: $phone, 코드: $code"); + try { + final result = await AuthProxyService.verifySmsCode(phone, code); + final token = result['token']; + print("[Frontend] SMS 코드 검증 성공. JWT 수신: $token"); + // TODO: Handle the JWT token from the result, e.g., result['token'] + _showSuccessDialog(); + } catch (e) { + print("[Frontend] SMS 코드 검증 실패: $e"); + _showError("Failed to verify code: $e"); + } } void _showError(String message) {