로그인 · 회원가입 흐름을 서버 계정·약관 동의와 연결
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
|
||||
import '../../core/firebase/firebase_boot.dart';
|
||||
import 'auth.dart';
|
||||
import 'social_providers.dart';
|
||||
import '../../core/i18n/app_locale.dart';
|
||||
|
||||
/// 로그인 상태 보관소. 라우터가 이걸 듣고 로그인/셸을 가른다.
|
||||
class AuthRepository extends ChangeNotifier {
|
||||
@@ -35,6 +36,17 @@ class AuthRepository extends ChangeNotifier {
|
||||
AuthAccount? get account => _account;
|
||||
bool get isSignedIn => _account != null;
|
||||
|
||||
/// 간편 로그인 「회원가입」 모드로 막 인증을 마쳤다. 라우터가 이 값을 보고 가입 완료
|
||||
/// 화면(`182:29344`)을 한 번 끼운다. [finishSignup] 이 내린다.
|
||||
bool get justSignedUp => _justSignedUp;
|
||||
bool _justSignedUp = false;
|
||||
|
||||
void finishSignup() {
|
||||
if (!_justSignedUp) return;
|
||||
_justSignedUp = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// **별첨 B v1.4 확정 4종.** 순서는 회신 문구 순서다(화면 버튼은 Figma 순서로 다시 줄 세운다).
|
||||
///
|
||||
/// > 1차 로그인은 Google / Apple / Kakao / LINE 4종입니다. 이메일/비밀번호 가입 및
|
||||
@@ -76,7 +88,7 @@ class AuthRepository extends ChangeNotifier {
|
||||
}) async {
|
||||
final impl = qaEmailProvider;
|
||||
if (impl == null) {
|
||||
return const AuthFailed('E-AUTH-03', '이메일 로그인을 쓸 수 없습니다.');
|
||||
return AuthFailed('E-AUTH-03', appL10n.authEmailUnavailable);
|
||||
}
|
||||
late final AuthOutcome outcome;
|
||||
try {
|
||||
@@ -85,13 +97,16 @@ class AuthRepository extends ChangeNotifier {
|
||||
: await impl.signInWithEmail(email, password);
|
||||
} on Object catch (error) {
|
||||
debugPrint('[AuthRepository] email sign-in failed: ${error.runtimeType}');
|
||||
return const AuthFailed('E-AUTH-01', '이메일 또는 비밀번호를 확인해 주세요.');
|
||||
return AuthFailed('E-AUTH-01', appL10n.authCheckCredentials);
|
||||
}
|
||||
if (outcome is AuthSucceeded) _replaceAccount(outcome.account);
|
||||
return outcome;
|
||||
}
|
||||
|
||||
Future<AuthOutcome> signIn(SocialProvider provider) async {
|
||||
Future<AuthOutcome> signIn(
|
||||
SocialProvider provider, {
|
||||
bool signUp = false,
|
||||
}) async {
|
||||
final impl = providers.firstWhere(
|
||||
(p) => p.provider == provider,
|
||||
orElse: () => throw ArgumentError.value(
|
||||
@@ -109,9 +124,10 @@ class AuthRepository extends ChangeNotifier {
|
||||
debugPrint(
|
||||
'[AuthRepository] ${provider.name} sign-in failed: ${error.runtimeType}',
|
||||
);
|
||||
outcome = const AuthFailed('E-AUTH-03', '소셜 로그인에 실패했습니다.');
|
||||
outcome = AuthFailed('E-AUTH-03', appL10n.authSocialFailed);
|
||||
}
|
||||
if (outcome is AuthSucceeded) {
|
||||
_justSignedUp = signUp;
|
||||
_replaceAccount(outcome.account);
|
||||
}
|
||||
return outcome;
|
||||
@@ -165,6 +181,7 @@ class AuthRepository extends ChangeNotifier {
|
||||
}
|
||||
|
||||
void _replaceAccount(AuthAccount? next) {
|
||||
if (next == null) _justSignedUp = false;
|
||||
if (_sameAccount(_account, next)) return;
|
||||
_account = next;
|
||||
notifyListeners();
|
||||
|
||||
Reference in New Issue
Block a user