fix
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||
import 'package:prosappco/src/screens/calendar.dart';
|
||||
@@ -25,10 +24,6 @@ import 'package:prosappco/src/screens/solicitudes.dart';
|
||||
import 'firebase_options.dart';
|
||||
|
||||
void main() async {
|
||||
GoogleSignIn googleSignIn = GoogleSignIn(
|
||||
clientId:
|
||||
'245204384533-glsp6hf14uqvtn52jrn1f9ds3k3too8v.apps.googleusercontent.com');
|
||||
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
await initializeDateFormatting('es_MX', null);
|
||||
|
||||
@@ -14,9 +14,7 @@ class AuthenticationRepository extends GetxController {
|
||||
final _auth = FirebaseAuth.instance;
|
||||
late final Rx<User?> firebaseUser;
|
||||
final firebase = FirebaseFirestore.instance;
|
||||
final GoogleSignIn googleSignIn = GoogleSignIn(
|
||||
clientId:
|
||||
'245204384533-glsp6hf14uqvtn52jrn1f9ds3k3too8v.apps.googleusercontent.com');
|
||||
final GoogleSignIn googleSignIn = GoogleSignIn();
|
||||
// final _userRef = firebase
|
||||
var verificationId = ''.obs;
|
||||
|
||||
@@ -128,15 +126,29 @@ class AuthenticationRepository extends GetxController {
|
||||
Future<void> signInWithGoogle() async {
|
||||
try {
|
||||
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
|
||||
final GoogleSignInAuthentication googleAuth =
|
||||
await googleUser!.authentication;
|
||||
final credential = GoogleAuthProvider.credential(
|
||||
accessToken: googleAuth.accessToken,
|
||||
idToken: googleAuth.idToken,
|
||||
);
|
||||
await FirebaseAuth.instance.signInWithCredential(credential);
|
||||
|
||||
if (googleUser != null) {
|
||||
final GoogleSignInAuthentication googleAuth =
|
||||
await googleUser.authentication;
|
||||
final OAuthCredential credential = GoogleAuthProvider.credential(
|
||||
accessToken: googleAuth.accessToken,
|
||||
idToken: googleAuth.idToken,
|
||||
);
|
||||
|
||||
await FirebaseAuth.instance.signInWithCredential(credential);
|
||||
|
||||
// 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(ServiceScreen())
|
||||
: Get.to(LoginScreen());
|
||||
} else {
|
||||
// El usuario canceló el inicio de sesión con Google
|
||||
// Puedes manejarlo según tus necesidades
|
||||
print('Error');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error - ${e}');
|
||||
print('Error - $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user