로그인 · 회원가입 흐름을 서버 계정·약관 동의와 연결

This commit is contained in:
Sn-Kinos
2026-09-29 17:06:48 +09:00
parent 3aca678072
commit de44739e63
6 changed files with 133 additions and 99 deletions
@@ -3,6 +3,7 @@ import 'package:flutter/foundation.dart';
import 'auth.dart';
import 'social_providers.dart';
import '../../core/i18n/app_locale.dart';
/// 하나의 FANUZU UID 에 소셜 Provider 를 붙이고 떼는 Firebase 어댑터.
///
@@ -47,7 +48,7 @@ final class FirebaseAccountLinker implements AccountLinker {
Future<AuthOutcome> link(AuthProviderKind provider) async {
final user = _firebaseAuth.currentUser;
if (user == null) {
return const AuthFailed('E-AUTH-03', '로그인이 필요합니다.');
return AuthFailed('E-AUTH-03', appL10n.authLoginRequired);
}
final impl = _implOf(provider);
if (impl == null) {
@@ -77,7 +78,7 @@ final class FirebaseAccountLinker implements AccountLinker {
if (mine != null &&
theirs != null &&
!sameAccountIdentity(mine, theirs)) {
return const AuthFailed('E-AUTH-08', '가입하신 이메일과 다른 계정입니다.');
return AuthFailed('E-AUTH-08', appL10n.authDifferentEmail);
}
final result = await user.linkWithCredential(obtained.credential);
@@ -90,7 +91,7 @@ final class FirebaseAccountLinker implements AccountLinker {
} on Object catch (error) {
// SDK 가 문서화하지 않은 플랫폼 예외를 던져도 화면이 busy 에 고착되지 않게 닫는다.
debugPrint('[FirebaseAccountLinker] link failed: ${error.runtimeType}');
return const AuthFailed('E-AUTH-03', '계정 연결에 실패했습니다.');
return AuthFailed('E-AUTH-03', appL10n.authLinkFailed);
}
}
@@ -98,16 +99,16 @@ final class FirebaseAccountLinker implements AccountLinker {
Future<AuthOutcome> unlink(AuthProviderKind provider) async {
final user = _firebaseAuth.currentUser;
if (user == null) {
return const AuthFailed('E-AUTH-03', '로그인이 필요합니다.');
return AuthFailed('E-AUTH-03', appL10n.authLoginRequired);
}
// **마지막 하나는 떼지 않는다.** 떼는 순간 로그인 수단이 0개가 되어 계정에
// 다시 들어올 방법이 사라진다 — Firebase 는 이걸 막아 주지 않는다.
if (linkedAccounts.length <= 1) {
return const AuthFailed('E-AUTH-13', '마지막 로그인 수단은 연결을 해제할 수 없습니다.');
return AuthFailed('E-AUTH-13', appL10n.authLastProvider);
}
final id = providerIds[provider];
if (id == null) {
return const AuthFailed('E-AUTH-10', '연결되어 있지 않은 계정입니다.');
return AuthFailed('E-AUTH-10', appL10n.authNotLinked);
}
try {
await user.unlink(id);