38 lines
1.3 KiB
Dart
38 lines
1.3 KiB
Dart
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'app.dart';
|
|
import 'core/data/backend.dart';
|
|
import 'core/firebase/firebase_boot.dart';
|
|
import 'features/auth/auth_repository.dart';
|
|
import 'features/auth/firebase_auth_session.dart';
|
|
import 'features/auth/signup_screens.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
// 설정 파일이 없으면 목 모드로 내려간다. 여기서 throw 하지 않는다 — FirebaseBoot 참고.
|
|
await FirebaseBoot.init();
|
|
final live = FirebaseBoot.isLive;
|
|
runApp(
|
|
FancakeApp(
|
|
auth: AuthRepository(
|
|
session: live ? FirebaseAuthSession() : null,
|
|
needsTerms: live ? _needsTerms : null,
|
|
recordTerms: live
|
|
? (agreed) => Backend().call('fnSignupConsent', {
|
|
'agreed': agreed.toList(),
|
|
'version': signupTermsVersion,
|
|
})
|
|
: null,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 동의 기록(`termsAgreedAt`)이 없으면 약관을 받아야 한다. 갓 생성된 계정은 트리거가 아직
|
|
/// 사용자 문서를 만들지 않았을 수 있다 — 그래도 동의가 필요하다.
|
|
Future<bool> _needsTerms(String uid) async {
|
|
final snap = await FirebaseFirestore.instance.doc('users/$uid').get();
|
|
return snap.data()?['termsAgreedAt'] == null;
|
|
}
|