This commit is contained in:
Felipe
2023-11-17 11:58:11 -05:00
parent a0193bb43f
commit 6fe88bf31c
10 changed files with 266 additions and 781 deletions
@@ -1,11 +1,13 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:prosappco/src/authentication/exceptions/register_failed.dart';
import 'package:prosappco/src/presentation/screens/login/login.dart';
// import 'package:prosappco/src/presentation/screens/service.dart';
import 'package:prosappco/src/presentation/screens/map/service.dart';
import 'package:prosappco/src/presentation/screens/service_web.dart';
class AuthenticationRepository extends GetxController {
static AuthenticationRepository get instance => Get.find();
@@ -29,7 +31,9 @@ class AuthenticationRepository extends GetxController {
_setInitialScreen(User? user) {
user == null
? Get.offAll(const LoginScreen())
: Get.offAll(const ServiceScreen());
: kIsWeb
? Get.offAll(const ServiceWebScreen())
: Get.offAll(const ServiceScreen());
}
Future<void> phoneAuthentication(String phoneNo) async {
@@ -79,7 +83,9 @@ class AuthenticationRepository extends GetxController {
email: email, password: password);
firebaseUser.value != null
? Get.offAll(const ServiceScreen())
? kIsWeb
? Get.offAll(const ServiceWebScreen())
: Get.to(const ServiceScreen())
: Get.to(const LoginScreen());
} on FirebaseAuthException catch (e) {
final ex = SignUpWithEmailAndPasswordFailure.code(e.code);
@@ -140,7 +146,9 @@ class AuthenticationRepository extends GetxController {
// Continúa con el flujo de la aplicación después del inicio de sesión exitoso
// Por ejemplo, redirecciona a la siguiente pantalla
firebaseUser.value != null
? Get.offAll(const ServiceScreen())
? kIsWeb
? Get.offAll(const ServiceWebScreen())
: Get.to(const ServiceScreen())
: Get.to(const LoginScreen());
} else {
// El usuario canceló el inicio de sesión con Google
@@ -208,8 +216,6 @@ class AuthenticationRepository extends GetxController {
await FirebaseFirestore.instance.collection('users').doc(uid).get();
final Map<String, dynamic>? data = snapshot.data();
birthDate = data?['birth_date'] ?? '';
print('nada $birthDate');
} catch (e) {
print('Error getting birthDate: $e');
}