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

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
+17 -18
View File
@@ -8,6 +8,7 @@ import 'package:sign_in_with_apple/sign_in_with_apple.dart' as apple;
import '../../core/firebase/firebase_boot.dart';
import 'auth.dart';
import '../../core/i18n/app_locale.dart';
/// Firebase 자격증명을 만들 수 있는 제공자.
///
@@ -71,7 +72,7 @@ final class GoogleSignInProvider
try {
final obtained = await obtainCredential();
if (obtained == null) {
return const AuthFailed('E-AUTH-03', '소셜 로그인에 실패했습니다.');
return AuthFailed('E-AUTH-03', appL10n.authSocialFailed);
}
final result = await fb.FirebaseAuth.instance.signInWithCredential(
obtained.credential,
@@ -162,12 +163,12 @@ final class AppleSignInProvider
if (missing.isNotEmpty) return AuthNotConfigured(provider, missing);
if (!await apple.SignInWithApple.isAvailable()) {
return const AuthFailed('E-AUTH-03', '이 기기에서는 Apple 로그인을 쓸 수 없습니다.');
return AuthFailed('E-AUTH-03', appL10n.authAppleUnavailable);
}
try {
final obtained = await obtainCredential();
if (obtained == null) {
return const AuthFailed('E-AUTH-03', '소셜 로그인에 실패했습니다.');
return AuthFailed('E-AUTH-03', appL10n.authSocialFailed);
}
final result = await fb.FirebaseAuth.instance.signInWithCredential(
obtained.credential,
@@ -180,7 +181,7 @@ final class AppleSignInProvider
return AuthFailed('E-AUTH-03', error.message);
} on apple.SignInWithAppleException catch (error) {
debugPrint('[AppleSignInProvider] failed: ${error.runtimeType}');
return const AuthFailed('E-AUTH-03', '소셜 로그인에 실패했습니다.');
return AuthFailed('E-AUTH-03', appL10n.authSocialFailed);
} on fb.FirebaseAuthException catch (error) {
return AuthFailed(
authCatalogCode(error),
@@ -389,21 +390,21 @@ enum AuthFlow {
/// 사용자가 자기가 하지도 않은 계정 연결을 설명받고, 무엇을 해야 하는지 모른다.
String authMessage(fb.FirebaseAuthException error, {required AuthFlow flow}) =>
switch (error.code) {
'email-already-in-use' => '이미 가입된 이메일입니다.',
'weak-password' => '비밀번호가 너무 짧습니다. 8자 이상으로 정해 주세요.',
'invalid-email' => '이메일 형식이 올바르지 않습니다.',
'too-many-requests' => '잠시 후 다시 시도해 주세요.',
'email-already-in-use' => appL10n.authEmailInUse,
'weak-password' => appL10n.authWeakPassword,
'invalid-email' => appL10n.authInvalidEmail,
'too-many-requests' => appL10n.commonTryLater,
'account-exists-with-different-credential' => switch (flow) {
AuthFlow.signIn => _otherProviderSignInGuide(error.email),
AuthFlow.link => '다른 FANUZU 계정에 이미 연결된 소셜 계정입니다.',
AuthFlow.link => appL10n.authCredentialInUse,
},
// 붙이려는 자격증명이 남의 UID 에 이미 달려 있다. 연결 경로에서만 난다.
'credential-already-in-use' => '다른 FANUZU 계정에 이미 연결된 소셜 계정입니다.',
'provider-already-linked' => '이미 연결된 계정입니다.',
'no-such-provider' => '연결되어 있지 않은 계정입니다.',
'operation-not-allowed' => '이 로그인 수단은 아직 사용할 수 없습니다.',
'requires-recent-login' => '보안을 위해 다시 로그인한 뒤 시도해 주세요.',
_ => '이메일 또는 비밀번호를 확인해 주세요.',
'credential-already-in-use' => appL10n.authCredentialInUse,
'provider-already-linked' => appL10n.authAlreadyLinked,
'no-such-provider' => appL10n.authNotLinked,
'operation-not-allowed' => appL10n.authMethodUnavailable,
'requires-recent-login' => appL10n.authRecentLogin,
_ => appL10n.authCheckCredentials,
};
/// 「먼저 쓰던 수단으로 로그인한 뒤 SNS 연동에서 붙이라」는 안내.
@@ -422,6 +423,4 @@ String authMessage(fb.FirebaseAuthException error, {required AuthFlow flow}) =>
/// 따라 「은/는」이 갈려 `example.co은` 같은 문구가 나간다. 「계정」을 사이에 두면
/// 조사가 항상 맞는다.
String _otherProviderSignInGuide(String? email) =>
'${email ?? '이'} 계정은 다른 로그인 수단으로 가입돼 있습니다. '
'처음 가입에 쓰신 수단으로 로그인한 뒤 MY > 설정 > SNS 연동에서 '
'이 수단을 연결해 주세요.';
appL10n.authOtherProviderGuide(email ?? appL10n.authThisAccount);